本文整理汇总了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",
},
)