本文整理汇总了Python中pymongo.mongo_client.MongoClient.write_concern["w"]方法的典型用法代码示例。如果您正苦于以下问题:Python MongoClient.write_concern["w"]方法的具体用法?Python MongoClient.write_concern["w"]怎么用?Python MongoClient.write_concern["w"]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymongo.mongo_client.MongoClient
的用法示例。
在下文中一共展示了MongoClient.write_concern["w"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_concern
# 需要导入模块: from pymongo.mongo_client import MongoClient [as 别名]
# 或者: from pymongo.mongo_client.MongoClient import write_concern["w"] [as 别名]
def test_write_concern(self):
c = MongoClient(pair)
self.assertEqual({}, c.write_concern)
wc = {"w": 2, "wtimeout": 1000}
c.write_concern = wc
self.assertEqual(wc, c.write_concern)
wc = {"w": 3, "wtimeout": 1000}
c.write_concern["w"] = 3
self.assertEqual(wc, c.write_concern)
wc = {"w": 3}
del c.write_concern["wtimeout"]
self.assertEqual(wc, c.write_concern)
wc = {"w": 3, "wtimeout": 1000}
c = MongoClient(pair, w=3, wtimeout=1000)
self.assertEqual(wc, c.write_concern)
wc = {"w": 2, "wtimeout": 1000}
c.write_concern = wc
self.assertEqual(wc, c.write_concern)
db = c.pymongo_test
self.assertEqual(wc, db.write_concern)
coll = db.test
self.assertEqual(wc, coll.write_concern)
coll.write_concern = {"j": True}
self.assertEqual({"j": True}, coll.write_concern)
self.assertEqual(wc, db.write_concern)
wc = SON([("w", 2)])
coll.write_concern = wc
self.assertEqual(wc.to_dict(), coll.write_concern)
def f():
c.write_concern = {"foo": "bar"}
self.assertRaises(ConfigurationError, f)
def f():
c.write_concern["foo"] = "bar"
self.assertRaises(ConfigurationError, f)
def f():
c.write_concern = [("foo", "bar")]
self.assertRaises(ConfigurationError, f)