当前位置: 首页>>代码示例>>Python>>正文


Python DocumentFactory.get_absolute_url方法代码示例

本文整理汇总了Python中documents.factories.DocumentFactory.get_absolute_url方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentFactory.get_absolute_url方法的具体用法?Python DocumentFactory.get_absolute_url怎么用?Python DocumentFactory.get_absolute_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在documents.factories.DocumentFactory的用法示例。


在下文中一共展示了DocumentFactory.get_absolute_url方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_jsonification

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_absolute_url [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',
            }
        )
开发者ID:andyjia,项目名称:phase,代码行数:37,代码来源:test_models.py

示例2: test_jsonification

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_absolute_url [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",
            },
        )
开发者ID:thibault,项目名称:phase,代码行数:30,代码来源:test_models.py

示例3: test_edition_redirect

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_absolute_url [as 别名]
    def test_edition_redirect(self):
        """
        Tests that a document edition is redirected to the item
        or the list.
        """
        doc = DocumentFactory(
            category=self.category,
            document_key='FAC09001-FWF-000-HSE-REP-0004',
            metadata={
                'title': u'HAZOP related 1',
            },
            revision={
                'status': 'STD',
            }
        )
        c = self.client
        r = c.post(doc.get_edit_url(), {
            'document_number': doc.document_key,
            'title': u'a new title',
            'docclass': 1,
            'created_on': '2015-10-10',
            'received_date': '2015-10-10',
            'save-view': 'View',
        }, follow=True)
        self.assertEqual(
            r.redirect_chain,
            [('http://testserver{url}'.format(
                url=doc.get_absolute_url(),
            ), 302)]
        )

        r = c.post(doc.get_edit_url(), {
            'document_number': doc.document_key,
            'title': u'a new new title',
            'docclass': 1,
            'created_on': '2015-10-10',
            'received_date': '2015-10-10',
        }, follow=True)
        self.assertEqual(
            r.redirect_chain,
            [('http://testserver{url}'.format(
                url=self.category.get_absolute_url(),
            ), 302)]
        )
        # Check that update was logged in audit trail
        activity = Activity.objects.latest('created_on')
        self.assertEqual(activity.verb, Activity.VERB_EDITED)
        self.assertEqual(activity.target.title, u'a new new title')
        self.assertEqual(activity.actor, self.user)
开发者ID:andyjia,项目名称:phase,代码行数:51,代码来源:test_forms.py

示例4: test_document_related_documents

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_absolute_url [as 别名]
    def test_document_related_documents(self):
        documents = [
            DocumentFactory(document_key=u'HAZOP-related-1'),
            DocumentFactory(document_key=u'HAZOP-related-2'),
        ]
        document = DocumentFactory(
            document_key=u'HAZOP-report',
            category=self.category)
        document.metadata.related_documents = documents
        document.metadata.save()

        url = document.get_absolute_url()
        res = self.client.get(url, follow=True)
        self.assertContains(res, 'HAZOP-related-1')
        self.assertContains(res, 'HAZOP-related-2')
开发者ID:providenz,项目名称:phase,代码行数:17,代码来源:test_views.py


注:本文中的documents.factories.DocumentFactory.get_absolute_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。