本文整理汇总了Python中documents.factories.DocumentFactory.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentFactory.delete方法的具体用法?Python DocumentFactory.delete怎么用?Python DocumentFactory.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类documents.factories.DocumentFactory
的用法示例。
在下文中一共展示了DocumentFactory.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_command
# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import delete [as 别名]
def test_command(self):
document = DocumentFactory(
category=self.category,
)
native_doc = 'sample_doc_native.docx'
pdf_doc = 'sample_doc_pdf.pdf'
MetadataRevisionFactory(
metadata=document.get_metadata(),
revision=2,
native_file=SimpleUploadedFile(native_doc, b'content'),
pdf_file=SimpleUploadedFile(pdf_doc, b'content'),
)
# Document without files
DocumentFactory(
category=self.category,
)
rev = document.get_latest_revision()
filepath = rev.pdf_file.path
# check file is on disk after doc deletion
document.delete()
self.assertTrue(os.path.exists(filepath))
call_command('clearmedia')
# command has deleted file
self.assertFalse(os.path.exists(filepath))
示例2: test_deleted_document_is_unindexed
# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import delete [as 别名]
def test_deleted_document_is_unindexed(self, index_mock, unindex_mock):
doc = DocumentFactory(
category=self.category,
document_key='FAC09001-FWF-000-HSE-REP-0004',
)
doc.delete()
self.assertEqual(unindex_mock.call_count, 1)