本文整理匯總了Python中pymongo.replica_set_connection.ReplicaSetConnection.get_lasterror_options方法的典型用法代碼示例。如果您正苦於以下問題:Python ReplicaSetConnection.get_lasterror_options方法的具體用法?Python ReplicaSetConnection.get_lasterror_options怎麽用?Python ReplicaSetConnection.get_lasterror_options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymongo.replica_set_connection.ReplicaSetConnection
的用法示例。
在下文中一共展示了ReplicaSetConnection.get_lasterror_options方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_replica_set_connection
# 需要導入模塊: from pymongo.replica_set_connection import ReplicaSetConnection [as 別名]
# 或者: from pymongo.replica_set_connection.ReplicaSetConnection import get_lasterror_options [as 別名]
def test_replica_set_connection(self):
c = ReplicaSetConnection(pair, replicaSet=self.name)
self.assertTrue(c.auto_start_request)
self.assertFalse(c.slave_okay)
self.assertFalse(c.safe)
self.assertEqual({}, c.get_lasterror_options())
# ReplicaSetConnection's writes are unacknowledged by default
doc = {"_id": ObjectId()}
coll = c.pymongo_test.write_concern_test
coll.really_drop()
coll.insert(doc)
coll.insert(doc)
c = ReplicaSetConnection("mongodb://%s:%s/?replicaSet=%s&safe=true" % (
host, port, self.name))
self.assertTrue(c.safe)
# ReplicaSetConnection's network_timeout argument is translated into
# socketTimeoutMS
self.assertEqual(123, ReplicaSetConnection(
pair, replicaSet=self.name, network_timeout=123
)._MongoReplicaSetClient__net_timeout)
for network_timeout in 'foo', 0, -1:
self.assertRaises(ConfigurationError,
ReplicaSetConnection, pair, replicaSet=self.name,
network_timeout=network_timeout)
示例2: test_replica_set_connection
# 需要導入模塊: from pymongo.replica_set_connection import ReplicaSetConnection [as 別名]
# 或者: from pymongo.replica_set_connection.ReplicaSetConnection import get_lasterror_options [as 別名]
def test_replica_set_connection(self):
c = ReplicaSetConnection(pair, replicaSet=self.name)
ctx = catch_warnings()
try:
warnings.simplefilter("ignore", DeprecationWarning)
self.assertTrue(c.auto_start_request)
self.assertEqual(None, c.max_pool_size)
self.assertFalse(c.slave_okay)
self.assertFalse(c.safe)
self.assertEqual({}, c.get_lasterror_options())
# ReplicaSetConnection's writes are unacknowledged by default
doc = {"_id": ObjectId()}
coll = c.pymongo_test.write_concern_test
coll.drop()
coll.insert(doc)
coll.insert(doc)
c = ReplicaSetConnection("mongodb://%s:%s/?replicaSet=%s&safe=true" % (
host, port, self.name))
self.assertTrue(c.safe)
finally:
ctx.exit()
# To preserve legacy ReplicaSetConnection's behavior, max_size should
# be None. Pool should handle this without error.
pool = get_pool(c)
self.assertEqual(None, pool.max_size)
c.end_request()
# ReplicaSetConnection's network_timeout argument is translated into
# socketTimeoutMS
self.assertEqual(123, ReplicaSetConnection(
pair, replicaSet=self.name, network_timeout=123
)._MongoReplicaSetClient__net_timeout)
for network_timeout in 'foo', 0, -1:
self.assertRaises(
ConfigurationError,
ReplicaSetConnection, pair, replicaSet=self.name,
network_timeout=network_timeout)