本文整理汇总了Python中pymongo.mongo_client.MongoClient.get_document_class方法的典型用法代码示例。如果您正苦于以下问题:Python MongoClient.get_document_class方法的具体用法?Python MongoClient.get_document_class怎么用?Python MongoClient.get_document_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymongo.mongo_client.MongoClient
的用法示例。
在下文中一共展示了MongoClient.get_document_class方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init_disconnected
# 需要导入模块: from pymongo.mongo_client import MongoClient [as 别名]
# 或者: from pymongo.mongo_client.MongoClient import get_document_class [as 别名]
def test_init_disconnected(self):
c = MongoClient(host, port, _connect=False)
self.assertIsInstance(c.is_primary, bool)
self.assertIsInstance(c.is_mongos, bool)
self.assertIsInstance(c.max_pool_size, int)
self.assertIsInstance(c.use_greenlets, bool)
self.assertIsInstance(c.nodes, frozenset)
self.assertIsInstance(c.auto_start_request, bool)
self.assertEqual(dict, c.get_document_class())
self.assertIsInstance(c.tz_aware, bool)
self.assertIsInstance(c.max_bson_size, int)
self.assertIsInstance(c.min_wire_version, int)
self.assertIsInstance(c.max_wire_version, int)
self.assertEqual(None, c.host)
self.assertEqual(None, c.port)
c.pymongo_test.test.find_one() # Auto-connect.
self.assertEqual(host, c.host)
self.assertEqual(port, c.port)
if version.at_least(c, (2, 5, 4, -1)):
self.assertTrue(c.max_wire_version > 0)
else:
self.assertEqual(c.max_wire_version, 0)
self.assertTrue(c.min_wire_version >= 0)
bad_host = "somedomainthatdoesntexist.org"
c = MongoClient(bad_host, port, connectTimeoutMS=1, _connect=False)
self.assertRaises(ConnectionFailure, c.pymongo_test.test.find_one)
示例2: test_init_disconnected
# 需要导入模块: from pymongo.mongo_client import MongoClient [as 别名]
# 或者: from pymongo.mongo_client.MongoClient import get_document_class [as 别名]
def test_init_disconnected(self):
c = MongoClient(host, port, _connect=False)
ctx = catch_warnings()
try:
warnings.simplefilter("ignore", DeprecationWarning)
self.assertIsInstance(c.is_primary, bool)
self.assertIsInstance(c.is_mongos, bool)
self.assertIsInstance(c.max_pool_size, int)
self.assertIsInstance(c.use_greenlets, bool)
self.assertIsInstance(c.nodes, frozenset)
self.assertIsInstance(c.auto_start_request, bool)
self.assertEqual(dict, c.get_document_class())
self.assertIsInstance(c.tz_aware, bool)
self.assertIsInstance(c.max_bson_size, int)
self.assertIsInstance(c.min_wire_version, int)
self.assertIsInstance(c.max_wire_version, int)
self.assertIsInstance(c.max_write_batch_size, int)
self.assertEqual(None, c.host)
self.assertEqual(None, c.port)
finally:
ctx.exit()
c.pymongo_test.test.find_one() # Auto-connect.
self.assertEqual((host, port), c.address)
if version.at_least(c, (2, 5, 4, -1)):
self.assertTrue(c.max_wire_version > 0)
else:
self.assertEqual(c.max_wire_version, 0)
self.assertTrue(c.min_wire_version >= 0)
bad_host = "somedomainthatdoesntexist.org"
c = MongoClient(bad_host, port, connectTimeoutMS=1, _connect=False)
self.assertRaises(ConnectionFailure, c.pymongo_test.test.find_one)
示例3: test_init_disconnected
# 需要导入模块: from pymongo.mongo_client import MongoClient [as 别名]
# 或者: from pymongo.mongo_client.MongoClient import get_document_class [as 别名]
def test_init_disconnected(self):
c = MongoClient(host, port, _connect=False)
# No errors
c.is_primary
c.is_mongos
c.max_pool_size
c.use_greenlets
c.nodes
c.auto_start_request
c.get_document_class()
c.tz_aware
c.max_bson_size
self.assertEqual(None, c.host)
self.assertEqual(None, c.port)
c.pymongo_test.test.find_one() # Auto-connect.
self.assertEqual(host, c.host)
self.assertEqual(port, c.port)
bad_host = "somedomainthatdoesntexist.org"
c = MongoClient(bad_host, port, connectTimeoutMS=1,_connect=False)
self.assertRaises(ConnectionFailure, c.pymongo_test.test.find_one)