@@ -849,6 +849,58 @@ async def test_init_disconnected_with_auth(self):
849849 with self .assertRaises (ConnectionFailure ):
850850 await c .pymongo_test .test .find_one ()
851851
852+ @async_client_context .require_replica_set
853+ @async_client_context .require_no_load_balancer
854+ @async_client_context .require_tls
855+ async def test_init_disconnected_with_srv (self ):
856+ c = await self .async_rs_or_single_client (
857+ "mongodb+srv://test1.test.build.10gen.cc" , connect = False , tlsInsecure = True
858+ )
859+ # nodes returns an empty set if not connected
860+ self .assertEqual (c .nodes , frozenset ())
861+ # topology_description returns the initial seed description if not connected
862+ topology_description = c .topology_description
863+ self .assertEqual (topology_description .topology_type , TOPOLOGY_TYPE .Unknown )
864+ self .assertEqual (
865+ {
866+ ("test1.test.build.10gen.cc" , None ): ServerDescription (
867+ ("test1.test.build.10gen.cc" , None )
868+ )
869+ },
870+ topology_description .server_descriptions (),
871+ )
872+
873+ # address causes client to block until connected
874+ self .assertIsNotNone (await c .address )
875+ # Initial seed topology and connected topology have the same ID
876+ self .assertEqual (
877+ c ._topology ._topology_id , topology_description ._topology_settings ._topology_id
878+ )
879+ await c .close ()
880+
881+ c = await self .async_rs_or_single_client (
882+ "mongodb+srv://test1.test.build.10gen.cc" , connect = False , tlsInsecure = True
883+ )
884+ # primary causes client to block until connected
885+ await c .primary
886+ self .assertIsNotNone (c ._topology )
887+ await c .close ()
888+
889+ c = await self .async_rs_or_single_client (
890+ "mongodb+srv://test1.test.build.10gen.cc" , connect = False , tlsInsecure = True
891+ )
892+ # secondaries causes client to block until connected
893+ await c .secondaries
894+ self .assertIsNotNone (c ._topology )
895+ await c .close ()
896+
897+ c = await self .async_rs_or_single_client (
898+ "mongodb+srv://test1.test.build.10gen.cc" , connect = False , tlsInsecure = True
899+ )
900+ # arbiters causes client to block until connected
901+ await c .arbiters
902+ self .assertIsNotNone (c ._topology )
903+
852904 async def test_equality (self ):
853905 seed = "{}:{}" .format (* list (self .client ._topology_settings .seeds )[0 ])
854906 c = await self .async_rs_or_single_client (seed , connect = False )
0 commit comments