本文整理匯總了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)