def test_saving_director_unique_error_throw(self): director = Director(name='jane', surname='doe') director.full_clean() director.save() director2 = Director(name='jane', surname='doe') with self.assertRaises(ValidationError): director2.full_clean()
def test_updating_surname_validation_throw(self): director = Director(name='steven', surname='spilberg') director.full_clean() director.save() director.surname = 'a' * 41 with self.assertRaises(ValidationError): director.full_clean()
def test_saving_director_no_error_throw(self): director = Director(name='steven', surname='spilberg') director.full_clean() director.save() self.assertEqual(1, director.id) self.assertEqual('steven', director.name) self.assertEqual('spilberg', director.surname) self.assertIsNotNone(director.created)
def test_updating_name_none_should_validation_error_throw(self): director = Director(name='steven', surname='spilberg') director.full_clean() director.save() director.name = None with self.assertRaises(ValidationError): director.full_clean()
def test_updating_surname_no_error_throw(self): director = Director(name='ennio', surname='spilberg') director.full_clean() director.save() director.surname = 'McDoe' director.save() director.full_clean() director.refresh_from_db() self.assertEqual(Director.objects.count(), 1) self.assertEqual(1, director.id) self.assertEqual('ennio', director.name) self.assertEqual('McDoe', director.surname)
def test_updating_name_no_error_throw(self): director = Director(name='ennio', surname='spilberg') director.full_clean() director.save() created_date_src = director.created director.name = 'steven' director.save() director.full_clean() director.refresh_from_db() created_date_dest = director.created self.assertEqual(Director.objects.count(), 1) self.assertEqual(1, director.id) self.assertEqual('steven', director.name) self.assertEqual('spilberg', director.surname) self.assertEqual(created_date_dest, created_date_src)
def test_empty_name_should_throw_error(self): director = Director() with self.assertRaises(ValidationError): director.full_clean()
def test_too_long_surname_should_throw_error(self): director = Director(name='steven', surname='a' * 41) with self.assertRaises(ValidationError): director.full_clean()
def test_too_long_name_should_throw_error(self): director = Director(name='a' * 21, surname='spilberg') with self.assertRaises(ValidationError): director.full_clean()