7
7
from pubnub .models .consumer .pubsub import PNMessageResult
8
8
from pubnub .models .consumer .message_type import PNMessageType
9
9
from pubnub .pubnub_asyncio import PubNubAsyncio , AsyncioEnvelope , SubscribeListener
10
- from tests .helper import pnconf_sub_copy , pnconf_enc_sub_copy
10
+ from tests .helper import pnconf_env_copy , pnconf_enc_env_copy
11
11
from tests .integrational .vcr_asyncio_sleeper import get_sleeper , VCR599Listener , VCR599ReconnectionManager
12
12
from tests .integrational .vcr_helper import pn_vcr
13
13
@@ -19,13 +19,13 @@ async def patch_pubnub(pubnub):
19
19
pubnub ._subscription_manager ._reconnection_manager = VCR599ReconnectionManager (pubnub )
20
20
21
21
22
- @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/sub_unsub.yaml ' ,
23
- filter_query_parameters = ['uuid' , 'pnsdk' ])
22
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/sub_unsub.json ' ,
23
+ filter_query_parameters = ['uuid' , 'pnsdk' ], serializer = 'pn_json' )
24
24
@pytest .mark .asyncio
25
25
async def test_subscribe_unsubscribe (event_loop ):
26
26
channel = "test-subscribe-asyncio-ch"
27
27
28
- pubnub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
28
+ pubnub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
29
29
30
30
callback = SubscribeListener ()
31
31
pubnub .add_listener (callback )
@@ -49,12 +49,12 @@ async def test_subscribe_unsubscribe(event_loop):
49
49
await pubnub .stop ()
50
50
51
51
52
- @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/sub_pub_unsub.yaml ' ,
53
- filter_query_parameters = ['pnsdk' ])
52
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/sub_pub_unsub.json ' ,
53
+ filter_query_parameters = ['pnsdk' ], serializer = 'pn_json' )
54
54
@pytest .mark .asyncio
55
55
async def test_subscribe_publish_unsubscribe (event_loop ):
56
- pubnub_sub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
57
- pubnub_pub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
56
+ pubnub_sub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
57
+ pubnub_pub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
58
58
59
59
await patch_pubnub (pubnub_sub )
60
60
await patch_pubnub (pubnub_pub )
@@ -98,13 +98,11 @@ async def test_subscribe_publish_unsubscribe(event_loop):
98
98
await pubnub_sub .stop ()
99
99
100
100
101
- @pn_vcr .use_cassette (
102
- 'tests/integrational/fixtures/asyncio/subscription/sub_pub_unsub_enc.yaml' ,
103
- filter_query_parameters = ['pnsdk' ]
104
- )
101
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/sub_pub_unsub_enc.json' ,
102
+ filter_query_parameters = ['pnsdk' ], serializer = 'pn_json' )
105
103
@pytest .mark .asyncio
106
104
async def test_encrypted_subscribe_publish_unsubscribe (event_loop ):
107
- pubnub = PubNubAsyncio (pnconf_enc_sub_copy (), custom_event_loop = event_loop )
105
+ pubnub = PubNubAsyncio (pnconf_enc_env_copy (), custom_event_loop = event_loop )
108
106
pubnub .config .uuid = 'test-subscribe-asyncio-uuid'
109
107
110
108
with patch ("pubnub.crypto.PubNubCryptodome.get_initialization_vector" , return_value = "knightsofni12345" ):
@@ -143,14 +141,14 @@ async def test_encrypted_subscribe_publish_unsubscribe(event_loop):
143
141
await pubnub .stop ()
144
142
145
143
146
- @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/join_leave.yaml ' ,
147
- filter_query_parameters = ['pnsdk' , 'l_cg' ])
144
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/join_leave.json ' ,
145
+ filter_query_parameters = ['pnsdk' , 'l_cg' ], serializer = 'pn_json' )
148
146
@pytest .mark .asyncio
149
147
async def test_join_leave (event_loop ):
150
148
channel = "test-subscribe-asyncio-join-leave-ch"
151
149
152
- pubnub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
153
- pubnub_listener = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
150
+ pubnub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
151
+ pubnub_listener = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
154
152
155
153
await patch_pubnub (pubnub )
156
154
await patch_pubnub (pubnub_listener )
@@ -196,15 +194,15 @@ async def test_join_leave(event_loop):
196
194
await pubnub_listener .stop ()
197
195
198
196
199
- @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/cg_sub_unsub.yaml ' )
200
- @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/cg_sub_unsub.yaml ' ,
201
- filter_query_parameters = ['uuid' , 'pnsdk' , 'l_cg' , 'l_pres' ])
197
+ @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/cg_sub_unsub.json ' )
198
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/cg_sub_unsub.json ' ,
199
+ filter_query_parameters = ['uuid' , 'pnsdk' , 'l_cg' , 'l_pres' ], serializer = 'pn_json' )
202
200
@pytest .mark .asyncio
203
201
async def test_cg_subscribe_unsubscribe (event_loop , sleeper = asyncio .sleep ):
204
202
ch = "test-subscribe-asyncio-channel"
205
203
gr = "test-subscribe-asyncio-group"
206
204
207
- pubnub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
205
+ pubnub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
208
206
209
207
envelope = await pubnub .add_channel_to_channel_group ().channel_group (gr ).channels (ch ).future ()
210
208
assert envelope .status .original_response ['status' ] == 200
@@ -225,16 +223,16 @@ async def test_cg_subscribe_unsubscribe(event_loop, sleeper=asyncio.sleep):
225
223
await pubnub .stop ()
226
224
227
225
228
- @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/cg_sub_pub_unsub.yaml ' )
229
- @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/cg_sub_pub_unsub.yaml ' ,
230
- filter_query_parameters = ['uuid' , 'pnsdk' , 'l_cg' , 'l_pres' , 'l_pub' ])
226
+ @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/cg_sub_pub_unsub.json ' )
227
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/cg_sub_pub_unsub.json ' ,
228
+ filter_query_parameters = ['uuid' , 'pnsdk' , 'l_cg' , 'l_pres' , 'l_pub' ], serializer = 'pn_json' )
231
229
@pytest .mark .asyncio
232
230
async def test_cg_subscribe_publish_unsubscribe (event_loop , sleeper = asyncio .sleep ):
233
231
ch = "test-subscribe-asyncio-channel"
234
232
gr = "test-subscribe-asyncio-group"
235
233
message = "hey"
236
234
237
- pubnub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
235
+ pubnub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
238
236
239
237
envelope = await pubnub .add_channel_to_channel_group ().channel_group (gr ).channels (ch ).future ()
240
238
assert envelope .status .original_response ['status' ] == 200
@@ -269,13 +267,13 @@ async def test_cg_subscribe_publish_unsubscribe(event_loop, sleeper=asyncio.slee
269
267
await pubnub .stop ()
270
268
271
269
272
- @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/cg_join_leave.yaml ' )
273
- @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/cg_join_leave.yaml ' ,
274
- filter_query_parameters = ['pnsdk' , 'l_cg' , 'l_pres' ])
270
+ @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/cg_join_leave.json ' )
271
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/cg_join_leave.json ' ,
272
+ filter_query_parameters = ['pnsdk' , 'l_cg' , 'l_pres' ], serializer = 'pn_json' )
275
273
@pytest .mark .asyncio
276
274
async def test_cg_join_leave (event_loop , sleeper = asyncio .sleep ):
277
- pubnub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
278
- pubnub_listener = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
275
+ pubnub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
276
+ pubnub_listener = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
279
277
280
278
pubnub .config .uuid = "test-subscribe-asyncio-messenger"
281
279
pubnub_listener .config .uuid = "test-subscribe-asyncio-listener"
@@ -336,15 +334,13 @@ async def test_cg_join_leave(event_loop, sleeper=asyncio.sleep):
336
334
await pubnub_listener .stop ()
337
335
338
336
339
- @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/unsubscribe_all.yaml' )
340
- @pn_vcr .use_cassette (
341
- 'tests/integrational/fixtures/asyncio/subscription/unsubscribe_all.yaml' ,
342
- filter_query_parameters = ['pnsdk' , 'l_cg' , 'l_pres' ],
343
- match_on = ['method' , 'scheme' , 'host' , 'port' , 'string_list_in_path' , 'string_list_in_query' ],
344
- )
337
+ @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/unsubscribe_all.json' )
338
+ @pn_vcr .use_cassette ('tests/integrational/fixtures/asyncio/subscription/unsubscribe_all.json' ,
339
+ filter_query_parameters = ['pnsdk' , 'l_cg' , 'l_pres' ], serializer = 'pn_json' ,
340
+ match_on = ['method' , 'scheme' , 'host' , 'port' , 'string_list_in_path' , 'string_list_in_query' ])
345
341
@pytest .mark .asyncio
346
342
async def test_unsubscribe_all (event_loop , sleeper = asyncio .sleep ):
347
- pubnub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
343
+ pubnub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
348
344
349
345
pubnub .config .uuid = "test-subscribe-asyncio-messenger"
350
346
@@ -386,16 +382,16 @@ async def test_unsubscribe_all(event_loop, sleeper=asyncio.sleep):
386
382
await pubnub .stop ()
387
383
388
384
389
- @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/publish_space_id.yaml ' )
385
+ @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/publish_space_id.json ' )
390
386
@pn_vcr .use_cassette (
391
- 'tests/integrational/fixtures/asyncio/subscription/publish_space_id.yaml ' ,
387
+ 'tests/integrational/fixtures/asyncio/subscription/publish_space_id.json' , serializer = 'pn_json ' ,
392
388
filter_query_parameters = ['pnsdk' , 'l_cg' , 'l_pres' ],
393
389
match_on = ['method' , 'scheme' , 'host' , 'port' , 'string_list_in_path' , 'string_list_in_query' ],
394
390
)
395
391
@pytest .mark .asyncio
396
392
async def test_subscribe_publish_space_id (event_loop , sleeper = asyncio .sleep ):
397
- pubnub_sub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
398
- pubnub_pub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
393
+ pubnub_sub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
394
+ pubnub_pub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
399
395
400
396
await patch_pubnub (pubnub_sub )
401
397
await patch_pubnub (pubnub_pub )
@@ -443,16 +439,16 @@ async def test_subscribe_publish_space_id(event_loop, sleeper=asyncio.sleep):
443
439
await pubnub_sub .stop ()
444
440
445
441
446
- @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/publish_message_type.yaml ' )
442
+ @get_sleeper ('tests/integrational/fixtures/asyncio/subscription/publish_message_type.json ' )
447
443
@pn_vcr .use_cassette (
448
- 'tests/integrational/fixtures/asyncio/subscription/publish_message_type.yaml ' ,
444
+ 'tests/integrational/fixtures/asyncio/subscription/publish_message_type.json' , serializer = 'pn_json ' ,
449
445
filter_query_parameters = ['pnsdk' , 'l_cg' , 'l_pres' ],
450
446
match_on = ['method' , 'scheme' , 'host' , 'port' , 'string_list_in_path' , 'string_list_in_query' ],
451
447
)
452
448
@pytest .mark .asyncio
453
449
async def test_subscribe_publish_message_type (event_loop , sleeper = asyncio .sleep ):
454
- pubnub_sub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
455
- pubnub_pub = PubNubAsyncio (pnconf_sub_copy (), custom_event_loop = event_loop )
450
+ pubnub_sub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
451
+ pubnub_pub = PubNubAsyncio (pnconf_env_copy (), custom_event_loop = event_loop )
456
452
457
453
await patch_pubnub (pubnub_sub )
458
454
await patch_pubnub (pubnub_pub )
0 commit comments