Skip to content

Commit 1e95674

Browse files
committed
Swapped serializer for asyncio integrational subscribe tests
Fix tests for native sync publish Fix leaky serializer
1 parent 58d2215 commit 1e95674

24 files changed

+2611
-523
lines changed

tests/integrational/asyncio/test_subscribe.py

+41-45
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pubnub.models.consumer.pubsub import PNMessageResult
88
from pubnub.models.consumer.message_type import PNMessageType
99
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
1111
from tests.integrational.vcr_asyncio_sleeper import get_sleeper, VCR599Listener, VCR599ReconnectionManager
1212
from tests.integrational.vcr_helper import pn_vcr
1313

@@ -19,13 +19,13 @@ async def patch_pubnub(pubnub):
1919
pubnub._subscription_manager._reconnection_manager = VCR599ReconnectionManager(pubnub)
2020

2121

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')
2424
@pytest.mark.asyncio
2525
async def test_subscribe_unsubscribe(event_loop):
2626
channel = "test-subscribe-asyncio-ch"
2727

28-
pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
28+
pubnub = PubNubAsyncio(pnconf_env_copy(), custom_event_loop=event_loop)
2929

3030
callback = SubscribeListener()
3131
pubnub.add_listener(callback)
@@ -49,12 +49,12 @@ async def test_subscribe_unsubscribe(event_loop):
4949
await pubnub.stop()
5050

5151

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')
5454
@pytest.mark.asyncio
5555
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)
5858

5959
await patch_pubnub(pubnub_sub)
6060
await patch_pubnub(pubnub_pub)
@@ -98,13 +98,11 @@ async def test_subscribe_publish_unsubscribe(event_loop):
9898
await pubnub_sub.stop()
9999

100100

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')
105103
@pytest.mark.asyncio
106104
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)
108106
pubnub.config.uuid = 'test-subscribe-asyncio-uuid'
109107

110108
with patch("pubnub.crypto.PubNubCryptodome.get_initialization_vector", return_value="knightsofni12345"):
@@ -143,14 +141,14 @@ async def test_encrypted_subscribe_publish_unsubscribe(event_loop):
143141
await pubnub.stop()
144142

145143

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')
148146
@pytest.mark.asyncio
149147
async def test_join_leave(event_loop):
150148
channel = "test-subscribe-asyncio-join-leave-ch"
151149

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)
154152

155153
await patch_pubnub(pubnub)
156154
await patch_pubnub(pubnub_listener)
@@ -196,15 +194,15 @@ async def test_join_leave(event_loop):
196194
await pubnub_listener.stop()
197195

198196

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')
202200
@pytest.mark.asyncio
203201
async def test_cg_subscribe_unsubscribe(event_loop, sleeper=asyncio.sleep):
204202
ch = "test-subscribe-asyncio-channel"
205203
gr = "test-subscribe-asyncio-group"
206204

207-
pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
205+
pubnub = PubNubAsyncio(pnconf_env_copy(), custom_event_loop=event_loop)
208206

209207
envelope = await pubnub.add_channel_to_channel_group().channel_group(gr).channels(ch).future()
210208
assert envelope.status.original_response['status'] == 200
@@ -225,16 +223,16 @@ async def test_cg_subscribe_unsubscribe(event_loop, sleeper=asyncio.sleep):
225223
await pubnub.stop()
226224

227225

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')
231229
@pytest.mark.asyncio
232230
async def test_cg_subscribe_publish_unsubscribe(event_loop, sleeper=asyncio.sleep):
233231
ch = "test-subscribe-asyncio-channel"
234232
gr = "test-subscribe-asyncio-group"
235233
message = "hey"
236234

237-
pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
235+
pubnub = PubNubAsyncio(pnconf_env_copy(), custom_event_loop=event_loop)
238236

239237
envelope = await pubnub.add_channel_to_channel_group().channel_group(gr).channels(ch).future()
240238
assert envelope.status.original_response['status'] == 200
@@ -269,13 +267,13 @@ async def test_cg_subscribe_publish_unsubscribe(event_loop, sleeper=asyncio.slee
269267
await pubnub.stop()
270268

271269

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')
275273
@pytest.mark.asyncio
276274
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)
279277

280278
pubnub.config.uuid = "test-subscribe-asyncio-messenger"
281279
pubnub_listener.config.uuid = "test-subscribe-asyncio-listener"
@@ -336,15 +334,13 @@ async def test_cg_join_leave(event_loop, sleeper=asyncio.sleep):
336334
await pubnub_listener.stop()
337335

338336

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'])
345341
@pytest.mark.asyncio
346342
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)
348344

349345
pubnub.config.uuid = "test-subscribe-asyncio-messenger"
350346

@@ -386,16 +382,16 @@ async def test_unsubscribe_all(event_loop, sleeper=asyncio.sleep):
386382
await pubnub.stop()
387383

388384

389-
@get_sleeper('tests/integrational/fixtures/asyncio/subscription/publish_space_id.yaml')
385+
@get_sleeper('tests/integrational/fixtures/asyncio/subscription/publish_space_id.json')
390386
@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',
392388
filter_query_parameters=['pnsdk', 'l_cg', 'l_pres'],
393389
match_on=['method', 'scheme', 'host', 'port', 'string_list_in_path', 'string_list_in_query'],
394390
)
395391
@pytest.mark.asyncio
396392
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)
399395

400396
await patch_pubnub(pubnub_sub)
401397
await patch_pubnub(pubnub_pub)
@@ -443,16 +439,16 @@ async def test_subscribe_publish_space_id(event_loop, sleeper=asyncio.sleep):
443439
await pubnub_sub.stop()
444440

445441

446-
@get_sleeper('tests/integrational/fixtures/asyncio/subscription/publish_message_type.yaml')
442+
@get_sleeper('tests/integrational/fixtures/asyncio/subscription/publish_message_type.json')
447443
@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',
449445
filter_query_parameters=['pnsdk', 'l_cg', 'l_pres'],
450446
match_on=['method', 'scheme', 'host', 'port', 'string_list_in_path', 'string_list_in_query'],
451447
)
452448
@pytest.mark.asyncio
453449
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)
456452

457453
await patch_pubnub(pubnub_sub)
458454
await patch_pubnub(pubnub_pub)

0 commit comments

Comments
 (0)