Esempio n. 1
0
 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()
Esempio n. 2
0
    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()
Esempio n. 3
0
 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)
Esempio n. 4
0
    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()
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
 def test_empty_name_should_throw_error(self):
     director = Director()
     with self.assertRaises(ValidationError):
         director.full_clean()
Esempio n. 8
0
 def test_too_long_surname_should_throw_error(self):
     director = Director(name='steven', surname='a' * 41)
     with self.assertRaises(ValidationError):
         director.full_clean()
Esempio n. 9
0
 def test_too_long_name_should_throw_error(self):
     director = Director(name='a' * 21, surname='spilberg')
     with self.assertRaises(ValidationError):
         director.full_clean()