예제 #1
0
 def test_creating_person_from_factory_using_paramters(self):
     person_mom = mommy.Mommy(Person)
     person = person_mom.make(happy=False, age=20, gender='M', name='John')
     self.assertEqual(person.age, 20)
     self.assertEqual(person.happy, False)
     self.assertEqual(person.name, 'John')
     self.assertEqual(person.gender, 'M')
예제 #2
0
 def test_creating_person_from_factory_using_paramters(self):
     person_mom = mommy.Mommy(models.Person)
     person = person_mom.make(happy=False, age=20, gender='M', name='John')
     assert person.age == 20
     assert person.happy == False
     assert person.name == 'John'
     assert person.gender == 'M'
예제 #3
0
    def test_raise_pretty_excpetion_if_model_not_found(self):
        with self.assertRaises(ModelNotFound) as context_manager:
            mommy.Mommy('not_existing.Model')
        exception = context_manager.exception

        self.assertEqual(
            exception.message,
            "could not find model 'Model' in the app 'not_existing'.")
예제 #4
0
    def test_raise_model_not_found(self):
        with self.assertRaises(ModelNotFound):
            mommy.Mommy('non_existing.Model')

        with self.assertRaises(ModelNotFound):
            mommy.Mommy('NonExistingModel')
예제 #5
0
 def test_do_not_fill_nullables_if_fill_nullables_is_false(self):
     mom = mommy.Mommy(Person, False)
     p = mom.make_one()
     self.assertTrue(p.bio == None)
예제 #6
0
 def test_fill_nullables_if_fill_nullables_is_true(self):
     mom = mommy.Mommy(Person, True)
     p = mom.make_one()
     self.assertTrue(isinstance(p.bio, basestring))
예제 #7
0
 def test_always_fill_nullables_if_value_provided_via_attrs(self):
     bio_data = 'some bio'
     mom = mommy.Mommy(Person, False)
     p = mom.make_one(bio=bio_data)
     self.assertEqual(p.bio, bio_data)