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')
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'
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'.")
def test_raise_model_not_found(self): with self.assertRaises(ModelNotFound): mommy.Mommy('non_existing.Model') with self.assertRaises(ModelNotFound): mommy.Mommy('NonExistingModel')
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)
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))
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)