def test_get_popular_movies_min_5_stars(self): profile = Profile.create_new_user('testing1', '*****@*****.**', 'testing1', date.today()) movie = Movie.get_details(11) Rating.set_rating_for_user(movie, 1, profile) movie = Movie.get_details(12) Rating.set_rating_for_user(movie, 2, profile) movie = Movie.get_details(13) Rating.set_rating_for_user(movie, 3, profile) movie = Movie.get_details(513) Rating.set_rating_for_user(movie, 4, profile) movie = Movie.get_details(5) Rating.set_rating_for_user(movie, 5, profile) # There should only be one result when getting movies with rating 5 or higher self.assertTrue(Movie.get_popular(min_rating=5)['total_items'] == 1)
def test_get_popular_movies_min_1_star(self): profile = Profile.create_new_user('testing1', '*****@*****.**', 'testing1', date.today()) movie = Movie.get_details(11) Rating.set_rating_for_user(movie, 1, profile) movie = Movie.get_details(12) Rating.set_rating_for_user(movie, 2, profile) movie = Movie.get_details(13) Rating.set_rating_for_user(movie, 3, profile) movie = Movie.get_details(513) Rating.set_rating_for_user(movie, 4, profile) movie = Movie.get_details(5) Rating.set_rating_for_user(movie, 5, profile) # All 5 movies should show up as results when the minimum rating required for a movie to be 'popular' is a 1 self.assertTrue(Movie.get_popular(min_rating=1)['total_items'] == 5)
def test_get_overall_most_popular(self): profile = Profile.create_new_user('testing5', '*****@*****.**', 'testing5', date.today()) movie = Movie.get_details(11) Rating.set_rating_for_user(movie,4,profile) movie = Movie.get_details(12) Rating.set_rating_for_user(movie,5,profile) movie = Movie.get_details(13) Rating.set_rating_for_user(movie,2,profile) results = Movie.get_popular(min_rating=3) self.assertTrue(results['total_items'] == 2)
def test_get_overall_most_popular(self): profile = Profile.create_new_user('testing5', '*****@*****.**', 'testing5', date.today()) movie = Movie.get_details(11) Rating.set_rating_for_user(movie, 4, profile) movie = Movie.get_details(12) Rating.set_rating_for_user(movie, 5, profile) movie = Movie.get_details(13) Rating.set_rating_for_user(movie, 2, profile) results = Movie.get_popular(min_rating=3) self.assertTrue(results['total_items'] == 2)