本文整理匯總了Python中documents.factories.DocumentFactory.refresh_from_db方法的典型用法代碼示例。如果您正苦於以下問題:Python DocumentFactory.refresh_from_db方法的具體用法?Python DocumentFactory.refresh_from_db怎麽用?Python DocumentFactory.refresh_from_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類documents.factories.DocumentFactory
的用法示例。
在下文中一共展示了DocumentFactory.refresh_from_db方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_new_revision_can_update_document_key
# 需要導入模塊: from documents.factories import DocumentFactory [as 別名]
# 或者: from documents.factories.DocumentFactory import refresh_from_db [as 別名]
def test_new_revision_can_update_document_key(self):
doc = DocumentFactory(
category=self.category,
document_key='FAC09001-FWF-000-HSE-REP-0004',
revision={
'status': 'STD',
}
)
url = reverse('document_revise', args=[
self.category.organisation.slug,
self.category.slug,
doc.document_key
])
self.client.post(url, {
'document_number': 'Another Document Number',
'title': doc.metadata.title,
'status': 'SPD',
'docclass': 1,
'created_on': '2015-10-10',
'revision_date': '2015-10-10',
'received_date': '2015-10-10',
}, follow=True)
doc.refresh_from_db()
self.assertEqual(doc.document_number, 'Another Document Number')
self.assertEqual(doc.document_key, 'ANOTHER-DOCUMENT-NUMBER')
metadata = doc.get_metadata()
self.assertEqual(metadata.document_number, 'Another Document Number')
self.assertEqual(metadata.document_key, 'ANOTHER-DOCUMENT-NUMBER')
示例2: test_edition_updates_document_key
# 需要導入模塊: from documents.factories import DocumentFactory [as 別名]
# 或者: from documents.factories.DocumentFactory import refresh_from_db [as 別名]
def test_edition_updates_document_key(self):
doc = DocumentFactory(
category=self.category,
document_key='FAC09001-FWF-000-HSE-REP-0004',
metadata={
'title': 'HAZOP related 1',
},
revision={
'status': 'STD',
}
)
c = self.client
c.post(doc.get_edit_url(), {
'document_number': 'New Document Number',
'title': 'a new title',
'docclass': 1,
'created_on': '2015-10-10',
'received_date': '2015-10-10',
'save-view': 'View',
}, follow=True)
doc.refresh_from_db()
self.assertEqual(doc.document_number, 'New Document Number')
self.assertEqual(doc.document_key, 'NEW-DOCUMENT-NUMBER')
metadata = doc.get_metadata()
self.assertEqual(metadata.document_number, 'New Document Number')
self.assertEqual(metadata.document_key, 'NEW-DOCUMENT-NUMBER')