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


Python DocumentFactory.get_edit_url方法代码示例

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


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

示例1: test_edition_redirect

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_edit_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

示例2: test_edition_updates_document_key

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

示例3: test_edition_success

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_edit_url [as 别名]
 def test_edition_success(self):
     """
     Tests that a document can be created with required fields.
     """
     original_number_of_document = Document.objects.all().count()
     doc = DocumentFactory(
         category=self.category,
         document_key='FAC09001-FWF-000-HSE-REP-0004',
         metadata={
             'title': 'HAZOP related 1',
         },
         revision={
             'status': 'STD',
         }
     )
     c = self.client
     r = c.post(doc.get_edit_url(), {
         'document_number': doc.document_key,
         'title': 'a new title',
     })
     if r.status_code == 302:
         self.assertEqual(
             original_number_of_document + 1,
             Document.objects.all().count()
         )
     else:
         # Debug purpose
         self.assertEqual(r.context['form'].errors, {})
开发者ID:Talengi,项目名称:phase,代码行数:30,代码来源:test_forms.py

示例4: test_edition_errors

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_edit_url [as 别名]
    def test_edition_errors(self):
        """
        Tests that a document can't be edited without required fields.
        """
        required_error = 'This field is required.'
        doc = DocumentFactory(
            category=self.category,
            document_key='FAC09001-FWF-000-HSE-REP-0004',
            metadata={
                'title': 'HAZOP related 1',
            },
            revision={
                'status': 'STD',
            }
        )
        c = self.client
        edit_url = doc.get_edit_url()
        r = c.get(edit_url)
        self.assertEqual(r.status_code, 200)

        r = c.post(edit_url, {'document_number': doc.document_key})
        self.assertEqual(r.status_code, 200)
        self.assertEqual(r.context['form'].errors, {
            'title': [required_error],
        })
开发者ID:Talengi,项目名称:phase,代码行数:27,代码来源:test_forms.py

示例5: DistributionListWidgetTests

# 需要导入模块: from documents.factories import DocumentFactory [as 别名]
# 或者: from documents.factories.DocumentFactory import get_edit_url [as 别名]
class DistributionListWidgetTests(CasperTestCase):
    def setUp(self):
        Model = ContentType.objects.get_for_model(ContractorDeliverable)
        self.category = CategoryFactory(
            category_template__metadata_model=Model)
        self.user = UserFactory(
            email='[email protected]',
            password='pass',
            is_superuser=True,
            category=self.category)
        self.client.login(email=self.user.email, password='pass')
        self.doc = DocumentFactory(
            category=self.category,
            metadata_factory_class=ContractorDeliverableFactory,
            revision_factory_class=ContractorDeliverableRevisionFactory,
        )
        url = self.doc.get_edit_url()
        self.url = '%s%s' % (self.live_server_url, url)
        self.test_file = os.path.join(
            os.path.dirname(__file__),
            'casper_tests',
            'tests.js'
        )

    def test_select_distribution_list(self):
        dl = DistributionListFactory(
            categories=[self.category],
            name='Team Cassoulet',
        )
        DistributionListFactory(
            categories=[self.category],
            name='Team Oui Oui et ses potes')

        self.assertTrue(self.casper(
            self.test_file,
            url=self.url,
            leader_id=dl.leader_id,
            approver_id=dl.approver_id,
        ))
开发者ID:providenz,项目名称:phase,代码行数:41,代码来源:test_js.py


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