当前位置: 首页>>代码示例>>Python>>正文


Python Connection._parse_uri方法代码示例

本文整理汇总了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/"))
开发者ID:benaranguren,项目名称:mongo-python-driver,代码行数:28,代码来源:test_connection.py


注:本文中的pymongo.connection.Connection._parse_uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。