Python factory.build() Examples
The following are 4
code examples of factory.build().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
factory
, or try the search function
.
Example #1
Source File: test_forms.py From credentials with GNU Affero General Public License v3.0 | 6 votes |
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)
Example #2
Source File: factories.py From udata with GNU Affero General Public License v3.0 | 5 votes |
def as_dict(cls, **kwargs): return factory.build(dict, FACTORY_CLASS=cls, **kwargs)
Example #3
Source File: test_admin_form.py From hypha with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #4
Source File: test_views.py From cookiecutter-django-rest with MIT License | 5 votes |
def setUp(self): self.url = reverse('user-list') self.user_data = factory.build(dict, FACTORY_CLASS=UserFactory)