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

Method test_split_hosts

test/test_uri_parser.py:54–81  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

52 self.assertEqual(("dev1@FOO.COM", ""), parse_userinfo("dev1%40FOO.COM:"))
53
54 def test_split_hosts(self):
55 self.assertRaises(ConfigurationError, split_hosts, "localhost:27017,")
56 self.assertRaises(ConfigurationError, split_hosts, ",localhost:27017")
57 self.assertRaises(ConfigurationError, split_hosts, "localhost:27017,,localhost:27018")
58 self.assertEqual(
59 [("localhost", 27017), ("example.com", 27017)], split_hosts("localhost,example.com")
60 )
61 self.assertEqual(
62 [("localhost", 27018), ("example.com", 27019)],
63 split_hosts("localhost:27018,example.com:27019"),
64 )
65 self.assertEqual(
66 [("/tmp/mongodb-27017.sock", None)], split_hosts("/tmp/mongodb-27017.sock")
67 )
68 self.assertEqual(
69 [("/tmp/mongodb-27017.sock", None), ("example.com", 27017)],
70 split_hosts("/tmp/mongodb-27017.sock,example.com:27017"),
71 )
72 self.assertEqual(
73 [("example.com", 27017), ("/tmp/mongodb-27017.sock", None)],
74 split_hosts("example.com:27017,/tmp/mongodb-27017.sock"),
75 )
76 self.assertRaises(ValueError, split_hosts, "::1", 27017)
77 self.assertRaises(ValueError, split_hosts, "[::1:27017")
78 self.assertRaises(ValueError, split_hosts, "::1")
79 self.assertRaises(ValueError, split_hosts, "::1]:27017")
80 self.assertEqual([("::1", 27017)], split_hosts("[::1]:27017"))
81 self.assertEqual([("::1", 27017)], split_hosts("[::1]"))
82
83 def test_split_options(self):
84 self.assertRaises(ConfigurationError, split_options, "foo")

Callers

nothing calls this directly

Calls 1

split_hostsFunction · 0.90

Tested by

no test coverage detected