def test_createProfile_whenValidEgn_shouldCreate(self): name = 'Doncho' age = 19 egn = '1234567890' profile = Profile(name=name, age=age, egn=egn) profile.full_clean() profile.save()
def test_createProfile_whenEgnContainsLetters_shouldRaise(self): name = 'Doncho' age = 19 egn = '12345678a0' with self.assertRaises(ValidationError) as context: profile = Profile(name=name, age=age, egn=egn) profile.full_clean() profile.save() self.assertIsNotNone(context.exception)
def test_createProfile_whenValidEgn_shouldCreate(self): name = 'Georgi' age = 21 egn = '1234567890' profile = Profile( name=name, age=age, egn=egn, ) profile.full_clean() profile.save()
def test_createProfile_whenInValidEgn_shouldRaise(self): name = 'Georgi' age = 21 egn = '123456789a' with self.assertRaises(ValidationError) as context: profile = Profile( name=name, age=age, egn=egn, ) profile.full_clean() profile.save() self.assertIsNotNone(context)