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

Method test_init_disconnected

test/test_client.py:824–852  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

822 connected(c)
823
824 def test_init_disconnected(self):
825 host, port = client_context.host, client_context.port
826 c = self.rs_or_single_client(connect=False)
827 # is_primary causes client to block until connected
828 self.assertIsInstance(c.is_primary, bool)
829 c = self.rs_or_single_client(connect=False)
830 self.assertIsInstance(c.is_mongos, bool)
831 c = self.rs_or_single_client(connect=False)
832 self.assertIsInstance(c.options.pool_options.max_pool_size, int)
833 self.assertIsInstance(c.nodes, frozenset)
834
835 c = self.rs_or_single_client(connect=False)
836 self.assertEqual(c.codec_options, CodecOptions())
837 c = self.rs_or_single_client(connect=False)
838 self.assertFalse(c.primary)
839 self.assertFalse(c.secondaries)
840 c = self.rs_or_single_client(connect=False)
841 self.assertIsInstance(c.topology_description, TopologyDescription)
842 self.assertEqual(c.topology_description, c._topology._description)
843 if client_context.is_rs:
844 # The primary's host and port are from the replica set config.
845 self.assertIsNotNone(c.address)
846 else:
847 self.assertEqual(c.address, (host, port))
848
849 bad_host = "somedomainthatdoesntexist.org"
850 c = self.simple_client(bad_host, port, connectTimeoutMS=1, serverSelectionTimeoutMS=10)
851 with self.assertRaises(ConnectionFailure):
852 c.pymongo_test.test.find_one()
853
854 def test_init_disconnected_with_auth(self):
855 uri = "mongodb://user:pass@somedomainthatdoesntexist"

Callers

nothing calls this directly

Calls 4

CodecOptionsClass · 0.90
rs_or_single_clientMethod · 0.80
simple_clientMethod · 0.45
find_oneMethod · 0.45

Tested by

no test coverage detected