當前位置: 首頁>>代碼示例>>Python>>正文


Python factory.build方法代碼示例

本文整理匯總了Python中factory.build方法的典型用法代碼示例。如果您正苦於以下問題:Python factory.build方法的具體用法?Python factory.build怎麽用?Python factory.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在factory的用法示例。


在下文中一共展示了factory.build方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_program_uuid

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import build [as 別名]
def test_program_uuid(self):
        """ Verify a ValidationError is raised if the program's authoring organizations have
        no certificate images. """
        sc = SiteConfigurationFactory()
        data = factory.build(dict, FACTORY_CLASS=ProgramCertificateFactory)
        data['site'] = sc.site.id

        form = ProgramCertificateAdminForm(data)
        with mock.patch.object(SiteConfiguration, 'get_program', return_value=self.BAD_MOCK_API_PROGRAM) as mock_method:
            self.assertFalse(form.is_valid())
            mock_method.assert_called_with(data['program_uuid'], ignore_cache=True)
            self.assertEqual(
                form.errors['program_uuid'][0],
                'All authoring organizations of the program MUST have a certificate image defined!'
            )

        form = ProgramCertificateAdminForm(data)
        with mock.patch.object(SiteConfiguration, 'get_program',
                               return_value=self.GOOD_MOCK_API_PROGRAM) as mock_method:
            self.assertFalse(form.is_valid())
            mock_method.assert_called_with(data['program_uuid'], ignore_cache=True)
            self.assertNotIn('program_uuid', form.errors) 
開發者ID:edx,項目名稱:credentials,代碼行數:24,代碼來源:test_forms.py

示例2: as_dict

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import build [as 別名]
def as_dict(cls, **kwargs):
        return factory.build(dict, FACTORY_CLASS=cls, **kwargs) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:4,代碼來源:factories.py

示例3: form_data

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import build [as 別名]
def form_data(num_appl_forms=0, num_review_forms=0, delete=0, stages=1, same_forms=False, form_stage_info=[1]):
    form_data = formset_base(
        'forms', num_appl_forms, delete, same=same_forms, factory=ApplicationFormFactory,
        form_stage_info=form_stage_info)
    review_form_data = formset_base('review_forms', num_review_forms, False, same=same_forms, factory=ReviewFormFactory)
    form_data.update(review_form_data)

    fund_data = factory.build(dict, FACTORY_CLASS=FundTypeFactory)
    fund_data['workflow_name'] = workflow_for_stages(stages)

    form_data.update(fund_data)
    form_data.update(approval_form='')
    return form_data 
開發者ID:OpenTechFund,項目名稱:hypha,代碼行數:15,代碼來源:test_admin_form.py

示例4: setUp

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import build [as 別名]
def setUp(self):
        self.url = reverse('user-list')
        self.user_data = factory.build(dict, FACTORY_CLASS=UserFactory) 
開發者ID:agconti,項目名稱:cookiecutter-django-rest,代碼行數:5,代碼來源:test_views.py


注:本文中的factory.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。