本文整理汇总了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)
示例2: as_dict
# 需要导入模块: import factory [as 别名]
# 或者: from factory import build [as 别名]
def as_dict(cls, **kwargs):
return factory.build(dict, FACTORY_CLASS=cls, **kwargs)
示例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
示例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)