def test_deleting_actor_shouldnt_remove_movie(self): director = Director(name='steven', surname='spilberg') director.save() movie = Movie(title='IT Crowd', director=Director.objects.get(pk=1)) movie.save() actor = Actor(name='jane', surname='doe') actor.save() movie.actor.add(actor) movie.save() actor.delete() self.assertEqual(0, Actor.objects.count()) self.assertEqual(1, Movie.objects.count())
def test_deleting_none_existing_actor_should_error_throw(self): actor = Actor(name='jane', surname='doe') with self.assertRaises(AssertionError): actor.delete()
def test_deleting_existing_actor_should_pass(self): actor = Actor(name='jane', surname='doe') actor.save() actor.delete() self.assertEqual(0, Actor.objects.count())