本文整理汇总了Python中pymongo.connection.Connection._parse_uri方法的典型用法代码示例。如果您正苦于以下问题:Python Connection._parse_uri方法的具体用法?Python Connection._parse_uri怎么用?Python Connection._parse_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymongo.connection.Connection
的用法示例。
在下文中一共展示了Connection._parse_uri方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_uri
# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import _parse_uri [as 别名]
def test_parse_uri(self):
self.assertEqual(([("localhost", 27017)], None, None, None),
Connection._parse_uri("localhost"))
self.assertRaises(InvalidURI, Connection._parse_uri, "http://foobar.com")
self.assertRaises(InvalidURI, Connection._parse_uri, "http://[email protected]")
self.assertEqual(([("localhost", 27017)], None, None, None),
Connection._parse_uri("mongodb://localhost"))
self.assertEqual(([("localhost", 27017)], None, "fred", "foobar"),
Connection._parse_uri("mongodb://fred:[email protected]"))
self.assertEqual(([("localhost", 27017)], "baz", "fred", "foobar"),
Connection._parse_uri("mongodb://fred:[email protected]lhost/baz"))
self.assertEqual(([("example1.com", 27017), ("example2.com", 27017)],
None, None, None),
Connection._parse_uri("mongodb://example1.com:27017,example2.com:27017"))
self.assertEqual(([("localhost", 27017),
("localhost", 27018),
("localhost", 27019)], None, None, None),
Connection._parse_uri("mongodb://localhost,localhost:27018,localhost:27019"))
self.assertEqual(([("localhost", 27018)], None, None, None),
Connection._parse_uri("localhost:27018"))
self.assertEqual(([("localhost", 27017)], "foo", None, None),
Connection._parse_uri("localhost/foo"))
self.assertEqual(([("localhost", 27017)], None, None, None),
Connection._parse_uri("localhost/"))