def test_create_profile_whenValidEgn_shouldCreateTheProfile(self): name = 'liusska' age = 19 egn = '1234567890' profile = Profile( name=name, age=age, egn=egn ) profile.save()
def test_getIndex_whenTwoProfiles_shouldRenderCorrect_templateWithTwooProfiles(self): profiles = ( Profile(name='id', age=1, egn='1234567890'), Profile(name='m', age=2, egn='0123456789'), ) [profile.save() for profile in profiles] response = self.test_client.get(reverse('profiles')) self.assertTemplateUsed(response, 'testing/index.html') profiles = response.context['profiles'] self.assertEqual(2, len(profiles)) form = response.context['form'] self.assertIsNotNone(form)
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)