Exemplo n.º 1
0
 def test_saving_actor_unique_error_throw(self):
     actor = Actor(name='jane', surname='doe')
     actor.full_clean()
     actor.save()
     actor2 = Actor(name='jane', surname='doe')
     with self.assertRaises(ValidationError):
         actor2.full_clean()
Exemplo n.º 2
0
    def test_updating_surname_validation_throw(self):
        actor = Actor(name='jane', surname='doe')
        actor.full_clean()
        actor.save()

        actor.surname = 'a' * 41
        with self.assertRaises(ValidationError):
            actor.full_clean()
Exemplo n.º 3
0
 def test_saving_actor_no_error_throw(self):
     actor = Actor(name='jane', surname='doe')
     actor.full_clean()
     actor.save()
     self.assertEqual(1, actor.id)
     self.assertEqual('jane', actor.name)
     self.assertEqual('doe', actor.surname)
     self.assertIsNotNone(actor.created)
Exemplo n.º 4
0
    def test_updating_surname_none_should_validation_error_throw(self):
        actor = Actor(name='jane', surname='doe')
        actor.full_clean()
        actor.save()

        actor.surname = None
        with self.assertRaises(ValidationError):
            actor.full_clean()
Exemplo n.º 5
0
    def test_updating_surname_no_error_throw(self):
        actor = Actor(name='john', surname='doe')
        actor.full_clean()
        actor.save()

        actor.surname = 'McDoe'
        actor.save()
        actor.full_clean()
        actor.refresh_from_db()

        self.assertEqual(Actor.objects.count(), 1)
        self.assertEqual(1, actor.id)
        self.assertEqual('john', actor.name)
        self.assertEqual('McDoe', actor.surname)
Exemplo n.º 6
0
    def test_updating_name_no_error_throw(self):
        actor = Actor(name='john', surname='doe')
        actor.full_clean()
        actor.save()
        created_date_src = actor.created

        actor.name = 'jane'
        actor.save()
        actor.full_clean()
        actor.refresh_from_db()
        created_date_dest = actor.created

        self.assertEqual(Actor.objects.count(), 1)
        self.assertEqual(1, actor.id)
        self.assertEqual('jane', actor.name)
        self.assertEqual('doe', actor.surname)
        self.assertEqual(created_date_dest, created_date_src)
Exemplo n.º 7
0
 def test_empty_name_should_throw_error(self):
     actor = Actor()
     with self.assertRaises(ValidationError):
         actor.full_clean()
Exemplo n.º 8
0
 def test_too_long_surname_should_throw_error(self):
     actor = Actor(name='jane', surname='a' * 41)
     with self.assertRaises(ValidationError):
         actor.full_clean()