def test_should_assert_total_snapshots_to_equal_1(self, movie_snapshots_service): movie_snapshots_service.return_value.get_all.return_value = [ MovieSnapshotsBuilder.any_snapshot().finish() ] response = self.test_client.get("/movie-snapshots") movie_snapshots = response.json self.assertEqual(1, len(movie_snapshots))
def test_should_return_one_movie_snapshot_with_movie_title( self, movie_snapshots_repository): movie_snapshots_repository.return_value.get_all.return_value = [ MovieSnapshotsBuilder.snapshot_title("3 idiots").finish() ] movie_snapshot: MovieSnapshot = MovieSnapshotsService().get_all()[0] self.assertEqual("3 idiots", movie_snapshot.title)
def test_should_return_one_movie_snapshot_with_release_year( self, movie_snapshots_repository): movie_snapshots_repository.return_value.get_all.return_value = [ MovieSnapshotsBuilder.any_snapshot().released_on(date( 2009, 12, 25)).finish() ] movie_snapshot: MovieSnapshot = MovieSnapshotsService().get_all()[0] self.assertEqual(2009, movie_snapshot.release_year)
def test_should_return_one_movie_snapshot_with_movie_director( self, movie_snapshots_repository): movie_snapshots_repository.return_value.get_all.return_value = [ MovieSnapshotsBuilder.any_snapshot().directed_by( "Rajkumar").finish() ] movie_snapshot: MovieSnapshot = MovieSnapshotsService().get_all()[0] self.assertEqual("Rajkumar", movie_snapshot.director)
def test_should_save_all_movie_snapshots(self): movie_snapshot = MovieSnapshotsBuilder.snapshot_title("3 idiots") \ .directed_by("Rajkumar") \ .released_on(date(2019, 12, 25)) \ .add_rating_with("7/10", "internet") \ .finish() snapshots: List[MovieSnapshot] = MovieSnapshotsRepository().save_all( [movie_snapshot]) movie_snapshot = snapshots[0] snapshot_id = snapshots[0].id self.assertIsNotNone(snapshot_id) self.assertEqual("3 idiots", movie_snapshot.title) self.assertEqual("Rajkumar", movie_snapshot.director) self.assertEqual(date(2019, 12, 25), movie_snapshot.release_date) self.assertEqual("internet", movie_snapshot.ratings[0].source) self.assertEqual("7/10", movie_snapshot.ratings[0].value)
def test_should_assert_all_snapshots(self, movie_snapshots_service): movie_snapshot = MovieSnapshotsBuilder.snapshot_title("3 idiots") \ .directed_by("Rajkumar Hirani") \ .released_on(date(2009, 12, 25)) \ .add_rating_with(value="9/10", source="internet") \ .finish() expected_json = '[{"title": "3 idiots", "director": "Rajkumar Hirani", "release_year": 2009, "release_date": ' \ '"2009-12-25", "ratings": [{"value": "9/10", "source": "internet"}]}]' expected_movie_snapshot_views = json.loads(expected_json) movie_snapshots = [movie_snapshot] movie_snapshots_service.return_value.get_all.return_value = movie_snapshots response = self.test_client.get("/movie-snapshots") actual_movie_snapshot_views = response.json self.assertEqual(expected_movie_snapshot_views, actual_movie_snapshot_views)
def test_should_create_a_registered_snapshot_with_snapshot_id(self): registered_snapshot = RegisteredSnapshot.make_from( MovieSnapshotsBuilder.any_snapshot().snapshot_id(1000).finish()) self.assertEqual(1000, registered_snapshot.snapshot_id)
def test_should_create_a_registered_snapshot_with_snapshot_title(self): registered_snapshot = RegisteredSnapshot.make_from( MovieSnapshotsBuilder.snapshot_title("3 idiots").finish()) self.assertEqual("3 idiots", registered_snapshot.snapshot_title)
def test_should_create_movie_snapshot_view_with_title(self): movie_snapshot = MovieSnapshotsBuilder.snapshot_title( "3 idiots").finish() movie_snapshot_view = MovieSnapshotsView.make_from(movie_snapshot) self.assertEqual("3 idiots", movie_snapshot_view.title)
def test_should_create_movie_snapshot_view_with_a_rating_of_7_on_10(self): movie_snapshot = MovieSnapshotsBuilder.any_snapshot().add_rating_with( "7/10", "").finish() movie_snapshot_view = MovieSnapshotsView.make_from(movie_snapshot) self.assertEqual("7/10", movie_snapshot_view.ratings[0].value)
def test_should_create_movie_snapshot_view_with_a_rating_from_internet( self): movie_snapshot = MovieSnapshotsBuilder.any_snapshot().add_rating_with( "", "internet").finish() movie_snapshot_view = MovieSnapshotsView.make_from(movie_snapshot) self.assertEqual("internet", movie_snapshot_view.ratings[0].source)
def test_should_create_movie_snapshot_view_with_release_year(self): movie_snapshot = MovieSnapshotsBuilder.any_snapshot().released_on( date(2015, 12, 25)).finish() movie_snapshot_view = MovieSnapshotsView.make_from(movie_snapshot) self.assertEqual(2015, movie_snapshot_view.release_year)
def test_should_create_movie_snapshot_view_with_director(self): movie_snapshot = MovieSnapshotsBuilder.any_snapshot().directed_by( "Rajkumar").finish() movie_snapshot_view = MovieSnapshotsView.make_from(movie_snapshot) self.assertEqual("Rajkumar", movie_snapshot_view.director)