当前位置: 首页>>代码示例>>Python>>正文


Python recipe.Recipe类代码示例

本文整理汇总了Python中model_mommy.recipe.Recipe的典型用法代码示例。如果您正苦于以下问题:Python Recipe类的具体用法?Python Recipe怎么用?Python Recipe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Recipe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AddressResponseTests

class AddressResponseTests(TestCase):

    def setUp(self):
        self.recipe = Recipe(
            FormFieldResponse,
            form_field__kind='address',
            form_field__details={'required': True}
        )

    def test_should_pass_when_required_and_only_addr2_blank(self):
        field_response = self.recipe.prepare(details={
            'addressLine1': 'x', 'city': 'x', 'state': 'x', 'zip': 'x'
        })
        self.assertEqual(field_response.clean(), None)

    def test_should_not_pass_when_required_and_any_field_but_addr2_blank(self):
        field_response = self.recipe.prepare(details={
            'addressLine1': '', 'city': 'x', 'state': 'x', 'zip': 'x'
        })
        self.assertRaises(ValidationError, field_response.clean)

    def test_should_pass_when_not_required_and_all_fields_blank(self):
        field_response = self.recipe.prepare()
        field_response.form_field.details['required'] = False
        self.assertEqual(field_response.clean(), None)
开发者ID:jsayres,项目名称:dynamic-forms-example,代码行数:25,代码来源:test_form_field_response.py

示例2: LongAnswerResponseTests

class LongAnswerResponseTests(TestCase):

    def setUp(self):
        self.recipe = Recipe(
            FormFieldResponse,
            form_field__kind='long-answer',
            form_field__details={'required': True}
        )

    def test_should_pass_when_required_and_answer_not_blank(self):
        field_response = self.recipe.prepare(details={'answer': 'ok'})
        self.assertEqual(field_response.clean(), None)

    def test_should_not_pass_when_required_and_answer_not_provided(self):
        field_response = self.recipe.prepare(details={})
        self.assertRaises(ValidationError, field_response.clean)

    def test_should_not_pass_when_required_and_answer_blank(self):
        field_response = self.recipe.prepare(details={'answer': ''})
        self.assertRaises(ValidationError, field_response.clean)

    def test_should_pass_when_not_required_and_answer_not_provided(self):
        field_response = self.recipe.prepare(details={})
        field_response.form_field.details['required'] = False
        self.assertEqual(field_response.clean(), None)

    def test_should_pass_when_not_required_and_answer_blank(self):
        field_response = self.recipe.prepare(details={'answer': ''})
        field_response.form_field.details['required'] = False
        self.assertEqual(field_response.clean(), None)
开发者ID:jsayres,项目名称:dynamic-forms-example,代码行数:30,代码来源:test_form_field_response.py

示例3: test_always_calls_with_quantity

 def test_always_calls_with_quantity(self):
     with patch("test.generic.tests.test_recipes.choice") as choice_mock:
         choice.return_value = "foo"
         l = ["foo", "bar", "spam", "eggs"]
         r = Recipe(DummyBlankFieldsModel, blank_char_field=lambda: choice(l))
         r.make(_quantity=3)
         self.assertEqual(choice_mock.call_count, 3)
开发者ID:berinhard,项目名称:model_mommy,代码行数:7,代码来源:test_recipes.py

示例4: test_always_calls_with_quantity

 def test_always_calls_with_quantity(self):
     with patch('test.generic.tests.test_recipes.choice') as choice_mock:
         l = ['foo', 'bar', 'spam', 'eggs']
         r = Recipe(DummyBlankFieldsModel,
             blank_char_field = lambda: choice(l)
         )
         r.make(_quantity=3)
         self.assertEqual(choice_mock.call_count, 3)
开发者ID:lucassimon,项目名称:model_mommy,代码行数:8,代码来源:test_recipes.py

示例5: test_defining_recipes_str

    def test_defining_recipes_str(self):
        from model_mommy.recipe import seq

        p = Recipe("generic.Person", name=seq("foo"))
        try:
            p.make(_quantity=5)
        except AttributeError as e:
            self.fail("%s" % e)
开发者ID:berinhard,项目名称:model_mommy,代码行数:8,代码来源:test_recipes.py

示例6: leg_setup

 def leg_setup(self):
     self.survey_recipe = Recipe(models.Commutersurvey)
     self.all_modes = models.Mode.objects.all()
     self.leg_recipe = Recipe(
         models.Leg,
         checkin = self.survey_recipe.make(),
         mode = cycle(self.all_modes)
     )
开发者ID:greenstreetsinitiative,项目名称:checkin2015,代码行数:8,代码来源:tests.py

示例7: setUp

 def setUp(self):
     last_hour = datetime.now() - timedelta(hours=1)
     # Next hour has 1 minute more because the delay between
     # the creation of the event and the test execution
     next_hour = datetime.now() + timedelta(minutes=61)
     self.event_last_hour = Recipe(Event, ends=last_hour, published=True)
     self.event_next_hour = Recipe(Event, ends=next_hour, published=True)
     self.event_unpublished = Recipe(Event, ends=next_hour, published=False)
开发者ID:UFRB,项目名称:happening,代码行数:8,代码来源:test_views.py

示例8: test_defining_recipes_str

 def test_defining_recipes_str(self):
     from model_mommy.recipe import seq
     p = Recipe('generic.Person',
         name=seq('foo')
     )
     try:
         p.make(_quantity=5)
     except AttributeError, e:
         self.fail('%s' %e)
开发者ID:kevinlondon,项目名称:model_mommy,代码行数:9,代码来源:test_recipes.py

示例9: test_prepare_recipe_with_foreign_key

    def test_prepare_recipe_with_foreign_key(self):
        person_recipe = Recipe(Person, name='John Doe')
        dog_recipe = Recipe(Dog,
            owner=foreign_key(person_recipe),
        )
        dog = dog_recipe.prepare()

        self.assertIsNone(dog.id)
        self.assertIsNone(dog.owner.id)
开发者ID:berinhard,项目名称:model_mommy,代码行数:9,代码来源:test_recipes.py

示例10: test_always_calls_when_creating

 def test_always_calls_when_creating(self):
     with patch('test.generic.tests.test_recipes.choice') as choice_mock:
         choice.return_value = 'foo'
         l = ['foo', 'bar', 'spam', 'eggs']
         r = Recipe(DummyBlankFieldsModel,
             blank_char_field = lambda: choice(l)
         )
         r.make().blank_char_field
         r.make().blank_char_field
         self.assertEqual(choice_mock.call_count, 2)
开发者ID:AspireFintech,项目名称:model_mommy,代码行数:10,代码来源:test_recipes.py

示例11: test_only_iterators_not_iteratables_are_iterated

    def test_only_iterators_not_iteratables_are_iterated(self):
        """Ensure we only iterate explicit iterators.

        Consider "iterable" vs "iterator":

        Something like a string is "iterable", but not an "iterator". We don't
        want to iterate "iterables", only explicit "iterators".

        """
        r = Recipe(DummyBlankFieldsModel, blank_text_field="not an iterator, so don't iterate!")
        self.assertEqual(r.make().blank_text_field, "not an iterator, so don't iterate!")
开发者ID:berinhard,项目名称:model_mommy,代码行数:11,代码来源:test_recipes.py

示例12: test_make_recipe_without_all_model_needed_data

 def test_make_recipe_without_all_model_needed_data(self):
     person_recipe = Recipe(Person, name="John Doe")
     person = person_recipe.make()
     self.assertEqual("John Doe", person.name)
     self.assertTrue(person.nickname)
     self.assertTrue(person.age)
     self.assertTrue(person.bio)
     self.assertTrue(person.birthday)
     self.assertTrue(person.appointment)
     self.assertTrue(person.blog)
     self.assertTrue(person.wanted_games_qtd)
     self.assertTrue(person.id)
开发者ID:berinhard,项目名称:model_mommy,代码行数:12,代码来源:test_recipes.py

示例13: test_prepare_recipe_without_all_model_needed_data

 def test_prepare_recipe_without_all_model_needed_data(self):
     person_recipe = Recipe(Person, name='John Doe')
     person = person_recipe.prepare()
     self.assertEqual('John Doe', person.name)
     self.assertTrue(person.nickname)
     self.assertTrue(person.age)
     self.assertTrue(person.bio)
     self.assertTrue(person.birthday)
     self.assertTrue(person.appointment)
     self.assertTrue(person.blog)
     self.assertTrue(person.wanted_games_qtd)
     self.assertFalse(person.id)
开发者ID:lucassimon,项目名称:model_mommy,代码行数:12,代码来源:test_recipes.py

示例14: test_do_query_lookup_empty_recipes

    def test_do_query_lookup_empty_recipes(self):
        """
          It should not attempt to create other object when
          using query lookup syntax
        """
        dog_recipe = Recipe(Dog)
        dog = dog_recipe.make(owner__name='James')
        self.assertEqual(Person.objects.count(), 1)
        self.assertEqual(dog.owner.name, 'James')

        dog = dog_recipe.prepare(owner__name='Zezin')
        self.assertEqual(Person.objects.count(), 1)
        self.assertEqual(dog.owner.name, 'Zezin')
开发者ID:lucassimon,项目名称:model_mommy,代码行数:13,代码来源:test_recipes.py

示例15: setUp

 def setUp(self):
     self.endereco_base = 'Rua Baronesa, 175'
     self.cidade_base = 'Rio de Janeiro'
     self.lat_base = -22.8950148
     self.lng_base = -43.3542673
     self.imovel = mommy.make(Imovel)
     self.basic_imovel_recipe = Recipe(Imovel, latitude=None, longitude=None)
     imoveis_recipe = Recipe(Imovel,
                             endereco=self.endereco_base,
                             cidade=self.cidade_base,
                             latitude=self.lat_base,
                             longitude=self.lng_base,
                             disponivel=cycle([False, True])
                             )
     # Cria 9 imóveis alterando disponíveis e indisponíveis
     imoveis_recipe.make(_quantity=9)
开发者ID:diegorocha,项目名称:desafio-finxi,代码行数:16,代码来源:test_models.py


注:本文中的model_mommy.recipe.Recipe类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。