@@ -30,16 +30,24 @@ async def force_suspended(client):
3030 await client .connection ._when_state ('suspended' )
3131
3232
33+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
3334class TestRealtimePresenceBasics (BaseAsyncTestCase ):
3435 """Test basic presence operations: enter, leave, update."""
3536
3637 @pytest .fixture (autouse = True )
37- async def setup (self ):
38+ async def setup (self , use_binary_protocol ):
3839 """Set up test fixtures."""
3940 self .test_vars = await TestApp .get_test_vars ()
41+ self .use_binary_protocol = use_binary_protocol
4042
41- self .client1 = await TestApp .get_ably_realtime (client_id = 'client1' )
42- self .client2 = await TestApp .get_ably_realtime (client_id = 'client2' )
43+ self .client1 = await TestApp .get_ably_realtime (
44+ client_id = 'client1' ,
45+ use_binary_protocol = use_binary_protocol
46+ )
47+ self .client2 = await TestApp .get_ably_realtime (
48+ client_id = 'client2' ,
49+ use_binary_protocol = use_binary_protocol
50+ )
4351
4452 yield
4553
@@ -161,7 +169,7 @@ async def test_presence_anonymous_client_error(self):
161169 Test RTP8j: Anonymous clients cannot enter presence.
162170 """
163171 # Create client without clientId
164- client = await TestApp .get_ably_realtime ()
172+ client = await TestApp .get_ably_realtime (use_binary_protocol = self . use_binary_protocol )
165173 await client .connection .once_async ('connected' )
166174
167175 channel = client .channels .get (self .get_channel_name ('anonymous' ))
@@ -175,16 +183,24 @@ async def test_presence_anonymous_client_error(self):
175183 await client .close ()
176184
177185
186+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
178187class TestRealtimePresenceGet (BaseAsyncTestCase ):
179188 """Test presence.get() functionality."""
180189
181190 @pytest .fixture (autouse = True )
182- async def setup (self ):
191+ async def setup (self , use_binary_protocol ):
183192 """Set up test fixtures."""
184193 self .test_vars = await TestApp .get_test_vars ()
194+ self .use_binary_protocol = use_binary_protocol
185195
186- self .client1 = await TestApp .get_ably_realtime (client_id = 'client1' )
187- self .client2 = await TestApp .get_ably_realtime (client_id = 'client2' )
196+ self .client1 = await TestApp .get_ably_realtime (
197+ client_id = 'client1' ,
198+ use_binary_protocol = use_binary_protocol
199+ )
200+ self .client2 = await TestApp .get_ably_realtime (
201+ client_id = 'client2' ,
202+ use_binary_protocol = use_binary_protocol
203+ )
188204
189205 yield
190206
@@ -261,16 +277,24 @@ async def test_presence_enter_leave_get(self):
261277 assert len (members ) == 0
262278
263279
280+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
264281class TestRealtimePresenceSubscribe (BaseAsyncTestCase ):
265282 """Test presence.subscribe() functionality."""
266283
267284 @pytest .fixture (autouse = True )
268- async def setup (self ):
285+ async def setup (self , use_binary_protocol ):
269286 """Set up test fixtures."""
270287 self .test_vars = await TestApp .get_test_vars ()
288+ self .use_binary_protocol = use_binary_protocol
271289
272- self .client1 = await TestApp .get_ably_realtime (client_id = 'client1' )
273- self .client2 = await TestApp .get_ably_realtime (client_id = 'client2' )
290+ self .client1 = await TestApp .get_ably_realtime (
291+ client_id = 'client1' ,
292+ use_binary_protocol = use_binary_protocol
293+ )
294+ self .client2 = await TestApp .get_ably_realtime (
295+ client_id = 'client2' ,
296+ use_binary_protocol = use_binary_protocol
297+ )
274298
275299 yield
276300
@@ -327,16 +351,21 @@ def on_presence(msg):
327351 assert msg .action == PresenceAction .ENTER
328352
329353
354+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
330355class TestRealtimePresenceEnterClient (BaseAsyncTestCase ):
331356 """Test enterClient/updateClient/leaveClient functionality."""
332357
333358 @pytest .fixture (autouse = True )
334- async def setup (self ):
359+ async def setup (self , use_binary_protocol ):
335360 """Set up test fixtures."""
336361 self .test_vars = await TestApp .get_test_vars ()
362+ self .use_binary_protocol = use_binary_protocol
337363
338364 # Use wildcard auth for enterClient
339- self .client = await TestApp .get_ably_realtime (client_id = '*' )
365+ self .client = await TestApp .get_ably_realtime (
366+ client_id = '*' ,
367+ use_binary_protocol = use_binary_protocol
368+ )
340369
341370 yield
342371
@@ -407,13 +436,15 @@ async def test_leave_client(self):
407436 assert members [0 ].client_id == 'client2'
408437
409438
439+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
410440class TestRealtimePresenceConnectionLifecycle (BaseAsyncTestCase ):
411441 """Test presence behavior during connection lifecycle events."""
412442
413443 @pytest .fixture (autouse = True )
414- async def setup (self ):
444+ async def setup (self , use_binary_protocol ):
415445 """Set up test fixtures."""
416446 self .test_vars = await TestApp .get_test_vars ()
447+ self .use_binary_protocol = use_binary_protocol
417448 yield
418449
419450 async def test_presence_enter_without_connect (self ):
@@ -424,7 +455,10 @@ async def test_presence_enter_without_connect(self):
424455 channel_name = self .get_channel_name ('enter_without_connect' )
425456
426457 # Create listener client
427- listener_client = await TestApp .get_ably_realtime (client_id = 'listener' )
458+ listener_client = await TestApp .get_ably_realtime (
459+ client_id = 'listener' ,
460+ use_binary_protocol = self .use_binary_protocol
461+ )
428462 listener_channel = listener_client .channels .get (channel_name )
429463
430464 received = asyncio .Future ()
@@ -436,7 +470,10 @@ def on_presence(msg):
436470 await listener_channel .presence .subscribe (on_presence )
437471
438472 # Create client and enter before it's connected
439- enterer_client = await TestApp .get_ably_realtime (client_id = 'enterer' )
473+ enterer_client = await TestApp .get_ably_realtime (
474+ client_id = 'enterer' ,
475+ use_binary_protocol = self .use_binary_protocol
476+ )
440477 enterer_channel = enterer_client .channels .get (channel_name )
441478
442479 # Enter without waiting for connection
@@ -458,7 +495,10 @@ async def test_presence_enter_after_close(self):
458495 channel_name = self .get_channel_name ('enter_after_close' )
459496
460497 # Create listener
461- listener_client = await TestApp .get_ably_realtime (client_id = 'listener' )
498+ listener_client = await TestApp .get_ably_realtime (
499+ client_id = 'listener' ,
500+ use_binary_protocol = self .use_binary_protocol
501+ )
462502 listener_channel = listener_client .channels .get (channel_name )
463503
464504 second_enter_received = asyncio .Future ()
@@ -470,7 +510,10 @@ def on_presence(msg):
470510 await listener_channel .presence .subscribe (on_presence )
471511
472512 # Create enterer client
473- enterer_client = await TestApp .get_ably_realtime (client_id = 'enterer' )
513+ enterer_client = await TestApp .get_ably_realtime (
514+ client_id = 'enterer' ,
515+ use_binary_protocol = self .use_binary_protocol
516+ )
474517 enterer_channel = enterer_client .channels .get (channel_name )
475518
476519 await enterer_client .connection .once_async ('connected' )
@@ -502,7 +545,7 @@ async def test_presence_enter_closed_error(self):
502545 """
503546 channel_name = self .get_channel_name ('enter_closed' )
504547
505- client = await TestApp .get_ably_realtime ()
548+ client = await TestApp .get_ably_realtime (use_binary_protocol = self . use_binary_protocol )
506549 channel = client .channels .get (channel_name )
507550
508551 await client .connection .once_async ('connected' )
@@ -521,13 +564,15 @@ async def test_presence_enter_closed_error(self):
521564 await client .close ()
522565
523566
567+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
524568class TestRealtimePresenceAutoReentry (BaseAsyncTestCase ):
525569 """Test automatic re-entry of presence after connection suspension."""
526570
527571 @pytest .fixture (autouse = True )
528- async def setup (self ):
572+ async def setup (self , use_binary_protocol ):
529573 """Set up test fixtures."""
530574 self .test_vars = await TestApp .get_test_vars ()
575+ self .use_binary_protocol = use_binary_protocol
531576 yield
532577
533578 async def test_presence_auto_reenter_after_suspend (self ):
@@ -539,7 +584,10 @@ async def test_presence_auto_reenter_after_suspend(self):
539584 """
540585 channel_name = self .get_channel_name ('auto_reenter' )
541586
542- client = await TestApp .get_ably_realtime (client_id = 'test_client' )
587+ client = await TestApp .get_ably_realtime (
588+ client_id = 'test_client' ,
589+ use_binary_protocol = self .use_binary_protocol
590+ )
543591 channel = client .channels .get (channel_name )
544592
545593 await channel .attach ()
@@ -592,7 +640,10 @@ async def test_presence_auto_reenter_different_connid(self):
592640 channel_name = self .get_channel_name ('auto_reenter_different_connid' )
593641
594642 # Create observer client
595- observer_client = await TestApp .get_ably_realtime (client_id = 'observer' )
643+ observer_client = await TestApp .get_ably_realtime (
644+ client_id = 'observer' ,
645+ use_binary_protocol = self .use_binary_protocol
646+ )
596647 observer_channel = observer_client .channels .get (channel_name )
597648 await observer_channel .attach ()
598649
@@ -613,7 +664,8 @@ def on_presence(msg):
613664 # This tells the server to send LEAVE for presence members 5 seconds after disconnect
614665 client = await TestApp .get_ably_realtime (
615666 client_id = 'test_client' ,
616- transport_params = {'remainPresentFor' : 5000 }
667+ transport_params = {'remainPresentFor' : 5000 },
668+ use_binary_protocol = self .use_binary_protocol
617669 )
618670 channel = client .channels .get (channel_name )
619671
@@ -672,13 +724,15 @@ def on_presence(msg):
672724 await client .close ()
673725
674726
727+ @pytest .mark .parametrize ('use_binary_protocol' , [True , False ], ids = ['msgpack' , 'json' ])
675728class TestRealtimePresenceSyncBehavior (BaseAsyncTestCase ):
676729 """Test presence SYNC behavior and state management."""
677730
678731 @pytest .fixture (autouse = True )
679- async def setup (self ):
732+ async def setup (self , use_binary_protocol ):
680733 """Set up test fixtures."""
681734 self .test_vars = await TestApp .get_test_vars ()
735+ self .use_binary_protocol = use_binary_protocol
682736 yield
683737
684738 async def test_presence_refresh_on_detach (self ):
@@ -692,11 +746,17 @@ async def test_presence_refresh_on_detach(self):
692746 channel_name = self .get_channel_name ('refresh_on_detach' )
693747
694748 # Client that manages presence
695- manager_client = await TestApp .get_ably_realtime (client_id = '*' )
749+ manager_client = await TestApp .get_ably_realtime (
750+ client_id = '*' ,
751+ use_binary_protocol = self .use_binary_protocol
752+ )
696753 manager_channel = manager_client .channels .get (channel_name )
697754
698755 # Observer client that will detach/reattach
699- observer_client = await TestApp .get_ably_realtime (client_id = 'observer' )
756+ observer_client = await TestApp .get_ably_realtime (
757+ client_id = 'observer' ,
758+ use_binary_protocol = self .use_binary_protocol
759+ )
700760 observer_channel = observer_client .channels .get (channel_name )
701761
702762 # Enter two members
@@ -756,9 +816,18 @@ async def test_suspended_preserves_presence(self):
756816 channel_name = self .get_channel_name ('suspended_preserves' )
757817
758818 # Create multiple clients
759- main_client = await TestApp .get_ably_realtime (client_id = 'main' )
760- continuous_client = await TestApp .get_ably_realtime (client_id = 'continuous' )
761- leaves_client = await TestApp .get_ably_realtime (client_id = 'leaves' )
819+ main_client = await TestApp .get_ably_realtime (
820+ client_id = 'main' ,
821+ use_binary_protocol = self .use_binary_protocol
822+ )
823+ continuous_client = await TestApp .get_ably_realtime (
824+ client_id = 'continuous' ,
825+ use_binary_protocol = self .use_binary_protocol
826+ )
827+ leaves_client = await TestApp .get_ably_realtime (
828+ client_id = 'leaves' ,
829+ use_binary_protocol = self .use_binary_protocol
830+ )
762831
763832 main_channel = main_client .channels .get (channel_name )
764833 continuous_channel = continuous_client .channels .get (channel_name )
0 commit comments