本文整理匯總了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)