本文整理匯總了Python中documents.factories.DocumentFactory.to_json方法的典型用法代碼示例。如果您正苦於以下問題:Python DocumentFactory.to_json方法的具體用法?Python DocumentFactory.to_json怎麽用?Python DocumentFactory.to_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類documents.factories.DocumentFactory
的用法示例。
在下文中一共展示了DocumentFactory.to_json方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_jsonification
# 需要導入模塊: from documents.factories import DocumentFactory [as 別名]
# 或者: from documents.factories.DocumentFactory import to_json [as 別名]
def test_jsonification(self):
"""Tests that a jsonified document returns the appropriate values."""
date = datetime.datetime(2013, 04, 20, 12, 0, 0, tzinfo=utc)
document = DocumentFactory(
document_key='FAC09001-FWF-000-HSE-REP-0004',
created_on=date,
current_revision_date=date,
metadata={
'title': 'HAZOP report',
},
revision={
'status': 'STD',
'revision_date': date,
'created_on': date,
'updated_on': date,
}
)
self.assertEqual(
document.to_json(),
{
u'status': u'STD',
u'title': u'HAZOP report',
u'url': document.get_absolute_url(),
u'revision': 1,
u'is_latest_revision': True,
u'pk': document.metadata.latest_revision.pk,
u'document_pk': document.pk,
u'metadata_pk': document.metadata.pk,
u'document_key': 'FAC09001-FWF-000-HSE-REP-0004',
u'document_number': 'FAC09001-FWF-000-HSE-REP-0004',
}
)
示例2: test_jsonification
# 需要導入模塊: from documents.factories import DocumentFactory [as 別名]
# 或者: from documents.factories.DocumentFactory import to_json [as 別名]
def test_jsonification(self):
"""Tests that a jsonified document returns the appropriate values."""
date = datetime.datetime(2013, 04, 20, 12, 0, 0, tzinfo=utc)
document = DocumentFactory(
document_key="FAC09001-FWF-000-HSE-REP-0004",
created_on=date,
current_revision_date=date,
metadata={"title": "HAZOP report"},
revision={"status": "STD", "revision_date": date, "created_on": date, "updated_on": date},
)
self.assertEqual(
document.to_json(),
{
"status": "STD",
"title": "HAZOP report",
"url": document.get_absolute_url(),
"revision": 1,
"is_latest_revision": True,
"pk": document.metadata.latest_revision.pk,
"document_pk": document.pk,
"metadata_pk": document.metadata.pk,
"document_key": "FAC09001-FWF-000-HSE-REP-0004",
"document_number": "FAC09001-FWF-000-HSE-REP-0004",
},
)