当前位置: 首页>>代码示例>>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;未经允许,请勿转载。