MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_constants

Method test_constants

test/asynchronous/test_client.py:820–847  ·  view source on GitHub ↗

This test uses AsyncMongoClient explicitly to make sure that host and port are not overloaded.

(self)

Source from the content-addressed store, hash-verified

818 self.assertEqual(1, len(server._pool.conns))
819
820 async def test_constants(self):
821 """This test uses AsyncMongoClient explicitly to make sure that host and
822 port are not overloaded.
823 """
824 host, port = await async_client_context.host, await async_client_context.port
825 kwargs: dict = async_client_context.default_client_options.copy()
826 if async_client_context.auth_enabled:
827 kwargs["username"] = db_user
828 kwargs["password"] = db_pwd
829
830 # Set bad defaults.
831 AsyncMongoClient.HOST = "somedomainthatdoesntexist.org"
832 AsyncMongoClient.PORT = 123456789
833 with self.assertRaises(AutoReconnect):
834 c = self.simple_client(serverSelectionTimeoutMS=10, **kwargs)
835 await connected(c)
836
837 c = self.simple_client(host, port, **kwargs)
838 # Override the defaults. No error.
839 await connected(c)
840
841 # Set good defaults.
842 AsyncMongoClient.HOST = host
843 AsyncMongoClient.PORT = port
844
845 # No error.
846 c = self.simple_client(**kwargs)
847 await connected(c)
848
849 async def test_init_disconnected(self):
850 host, port = await async_client_context.host, await async_client_context.port

Callers

nothing calls this directly

Calls 3

connectedFunction · 0.90
copyMethod · 0.80
simple_clientMethod · 0.45

Tested by

no test coverage detected