コード例 #1
0
    def test_deleting_existing_director_should_remove_movie(self):
        director = Director(name='steven', surname='spilberg')
        director.save()
        movie = Movie(title='IT Crowd', director=Director.objects.get(pk=1))
        movie.save()

        director.delete()
        self.assertEqual(0, Director.objects.count())
        self.assertEqual(0, Movie.objects.count())
コード例 #2
0
    def test_deleting_none_existing_director_should_error_throw(self):
        director = Director(name='steven', surname='spilberg')

        with self.assertRaises(AssertionError):
            director.delete()
コード例 #3
0
    def test_deleting_existing_director_should_pass(self):
        director = Director(name='steven', surname='spilberg')
        director.save()

        director.delete()
        self.assertEqual(0, Director.objects.count())