本文整理汇总了Python中cloudant.document.Document.list_field_remove方法的典型用法代码示例。如果您正苦于以下问题:Python Document.list_field_remove方法的具体用法?Python Document.list_field_remove怎么用?Python Document.list_field_remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudant.document.Document
的用法示例。
在下文中一共展示了Document.list_field_remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_list_field_remove_successfully
# 需要导入模块: from cloudant.document import Document [as 别名]
# 或者: from cloudant.document.Document import list_field_remove [as 别名]
def test_list_field_remove_successfully(self):
"""
Test the static helper method to successfully remove from a list field.
"""
doc = Document(self.db)
self.assertEqual(doc, {})
doc.list_field_append(doc, 'pets', 'cat')
doc.list_field_append(doc, 'pets', 'dog')
self.assertEqual(doc, {'pets': ['cat', 'dog']})
doc.list_field_remove(doc, 'pets', 'dog')
self.assertEqual(doc, {'pets': ['cat']})
示例2: test_list_field_remove_failure
# 需要导入模块: from cloudant.document import Document [as 别名]
# 或者: from cloudant.document.Document import list_field_remove [as 别名]
def test_list_field_remove_failure(self):
"""
Test the static helper method to remove from a list
field errors as expected.
"""
doc = Document(self.db)
doc.field_set(doc, 'name', 'julia')
try:
doc.list_field_remove(doc, 'name', 'julia')
self.fail('Above statement should raise an Exception')
except CloudantException, err:
self.assertEqual(str(err), 'The field name is not a list.')
示例3: test_update_actions
# 需要导入模块: from cloudant.document import Document [as 别名]
# 或者: from cloudant.document.Document import list_field_remove [as 别名]
def test_update_actions(self):
"""
_test_update_actions_
"""
doc = {
"foo": "bar",
"baz": [1, 2, 3, 4, 5]
}
c_doc = Document(self.database, "HOWARD")
c_doc.list_field_append(doc, "baz", 10)
c_doc.list_field_remove(doc, "baz", 3)
c_doc.field_set(doc, "foo", "qux")
self.assertTrue(10 in doc['baz'])
self.assertFalse(3 in doc['baz'])
self.assertEqual(doc['foo'], "qux")