@@ -879,6 +879,57 @@ async def test_unsubscribe():
879879 mock1 .assert_called_once_with (ANY , False , False )
880880
881881
882+ # -----------------------------------------------------------------------------
883+ @pytest .mark .asyncio
884+ async def test_discover_all ():
885+ [client , server ] = LinkedDevices ().devices [:2 ]
886+
887+ characteristic1 = Characteristic (
888+ 'FDB159DB-036C-49E3-B3DB-6325AC750806' ,
889+ Characteristic .Properties .READ | Characteristic .Properties .NOTIFY ,
890+ Characteristic .READABLE ,
891+ bytes ([1 , 2 , 3 ]),
892+ )
893+
894+ descriptor1 = Descriptor ('2902' , 'READABLE,WRITEABLE' )
895+ descriptor2 = Descriptor ('AAAA' , 'READABLE,WRITEABLE' )
896+ characteristic2 = Characteristic (
897+ '3234C4F4-3F34-4616-8935-45A50EE05DEB' ,
898+ Characteristic .Properties .READ | Characteristic .Properties .NOTIFY ,
899+ Characteristic .READABLE ,
900+ bytes ([1 , 2 , 3 ]),
901+ descriptors = [descriptor1 , descriptor2 ],
902+ )
903+
904+ service1 = Service (
905+ '3A657F47-D34F-46B3-B1EC-698E29B6B829' ,
906+ [characteristic1 , characteristic2 ],
907+ )
908+ service2 = Service ('1111' , [])
909+ server .add_services ([service1 , service2 ])
910+
911+ await client .power_on ()
912+ await server .power_on ()
913+ connection = await client .connect (server .random_address )
914+ peer = Peer (connection )
915+
916+ await peer .discover_all ()
917+ assert len (peer .gatt_client .services ) == 3
918+ # service 1800 gets added automatically
919+ assert peer .gatt_client .services [0 ].uuid == UUID ('1800' )
920+ assert peer .gatt_client .services [1 ].uuid == service1 .uuid
921+ assert peer .gatt_client .services [2 ].uuid == service2 .uuid
922+ s = peer .get_services_by_uuid (service1 .uuid )
923+ assert len (s ) == 1
924+ assert len (s [0 ].characteristics ) == 2
925+ c = peer .get_characteristics_by_uuid (uuid = characteristic2 .uuid , service = s [0 ])
926+ assert len (c ) == 1
927+ assert len (c [0 ].descriptors ) == 2
928+ s = peer .get_services_by_uuid (service2 .uuid )
929+ assert len (s ) == 1
930+ assert len (s [0 ].characteristics ) == 0
931+
932+
882933# -----------------------------------------------------------------------------
883934@pytest .mark .asyncio
884935async def test_mtu_exchange ():
0 commit comments