本文整理汇总了Python中cloudant.document.Document.delete_attachment方法的典型用法代码示例。如果您正苦于以下问题:Python Document.delete_attachment方法的具体用法?Python Document.delete_attachment怎么用?Python Document.delete_attachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudant.document.Document
的用法示例。
在下文中一共展示了Document.delete_attachment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_attachment_delete
# 需要导入模块: from cloudant.document import Document [as 别名]
# 或者: from cloudant.document.Document import delete_attachment [as 别名]
def test_attachment_delete(self):
"""
_test_attachment_delete_
"""
doc = Document(self.database, "DUCKUMENT")
doc_id = 'DUCKUMENT'
attachment = 'herpderp.txt'
mock_get = mock.Mock()
mock_get.raise_for_status = mock.Mock()
mock_get.status_code = 200
mock_get.json = mock.Mock()
mock_get.json.return_value = {'_id': doc_id, '_rev': '2-def'}
self.mock_session.get.return_value = mock_get
mock_del = mock.Mock()
mock_del.raise_for_status = mock.Mock()
mock_del.status_code = 200
mock_del.json = mock.Mock()
mock_del.json.return_value = {'id': doc_id, 'rev': '3-ghi', 'ok': True}
self.mock_session.delete.return_value = mock_del
resp = doc.delete_attachment(attachment)
self.assertEqual(resp['id'], doc_id)
self.assertTrue(self.mock_session.get.called)
self.assertTrue(self.mock_session.delete.called)