def test_remove_movie(self, watchlist): movie1 = Movie("The 100", 2016) movie2 = Movie("Bones", 2004) watchlist.add_movie(movie1) watchlist.add_movie(movie2) watchlist.remove_movie(movie2) assert watchlist.size() == 1
def test_repo_can_add_movie(in_memory_repo): movie = Movie('Tom', 2001) movie.director = Director('Tom') movie.actors = [Actor('Tom')] movie.runtime_minutes = 20 in_memory_repo.add_movie(movie) assert in_memory_repo.get_movie('Tom', 2001) == movie
def test_see_friend_minutes_watched(user, friend): user.send_friend_request(friend) friend.accept_pending_request(user) thisisamovie = Movie("Garlic Bread", 2020) thisisamovie.runtime_minutes = 69 friend.watch_movie(thisisamovie, 35) assert user.see_friend_minutes_watched(friend) == 69
def test_see_friend_watched_movies(user, friend): user.send_friend_request(friend) friend.accept_pending_request(user) friend.watch_movie(Movie("Garlic Bread", 2020), 35) assert user.see_friend_watched_movies(friend) == [ Movie("Garlic Bread", 2020) ]
def test_select_movie_to_watch(self, watchlist): assert watchlist.select_movie_to_watch(1) is None assert watchlist.select_movie_to_watch('a') is None movie1 = Movie("The 100", 2016) movie2 = Movie("Bones", 2004) watchlist.add_movie(movie1) watchlist.add_movie(movie2) assert watchlist.select_movie_to_watch(1) == movie2
def test_setter(watchlist): watchlist.add_movie(Movie("Moana", 2016)) new_watchlist = [Movie("Your Name", 2016), Movie("A Silent Voice", 2016)] watchlist.watchlist = new_watchlist assert watchlist.watchlist == [ Movie("Your Name", 2016), Movie("A Silent Voice", 2016) ]
def test_accessing_non_friend(user, friend): thisisamovie = Movie("Garlic Bread", 2020) thisisareview = Review(thisisamovie, "this is a review.", 9) thisisamovie.runtime_minutes = 69 friend.watch_movie(Movie("Garlic Bread", 2020), 35) friend.add_review(thisisareview) assert user.see_friend_watched_movies(friend) is None assert user.see_friend_reviews(friend) is None assert user.see_friend_minutes_watched(friend) is None
def test_iterator_reaches_final_element(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Your Name", 2016)) watchlist.add_movie(Movie("A Silent Voice", 2016)) iterator = iter(watchlist) next(watchlist) next(watchlist) next(watchlist) with pytest.raises(StopIteration): next(watchlist)
def movie(): return Movie( "Moana", 2016, "14", "In Ancient Polynesia, when a terrible curse incurred by the Demigod Maui reaches an impetuous Chieftain's daughter's island, she answers the Ocean's call to seek out the Demigod to set things right.", "Ron Clements", "Auli'i Cravalho, Dwayne Johnson, Rachel House, Temuera Morrison", "Animation,Adventure,Comedy")
def test_tag_construction(tag): assert tag.tag_name == 'Spongebob Squarepants' for movie in tag.tagged_movies: assert False assert not tag.is_applied_to(Movie("Barnacle Boy", 2020))
def test_repository_can_add_movie(in_memory_repo): movie = Movie( "Testing", 2020, 1001, "Testing description", "Ron Clements", "Auli'i Cravalho, Dwayne Johnson, Rachel House, Temuera Morrison", "Animation,Adventure,Comedy") in_memory_repo.add_movie(movie) assert in_memory_repo.get_movie(1001) is movie
def test_movie_less_than_operator(movie): movie_1 = movie movie_2 = Movie( "Inglourious Basterds", 2009, "78", "Quentin Tarantino", "In Nazi-occupied France during World War II, a plan to assassinate Nazi leaders by a group of Jewish U.S. soldiers coincides with a theatre owner's vengeful plans for the same.", "Brad Pitt, Diane Kruger, Eli Roth,Mélanie Laurent", "Adventure,Drama,War") assert movie_2 < movie_1
def test_init(self, movie): assert movie == Movie("The 100", 2016) assert movie.description == "" assert movie.director is None assert movie.actors == [] assert movie.genres == [] assert movie.runtime_minutes == 0 assert movie.rank is None assert movie.rating is None assert movie.votes is None assert movie.revenue is None assert movie.metascore is None
def test_iterator_used(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Your Name", 2016)) watchlist.add_movie(Movie("A Silent Voice", 2016)) iterator = iter(watchlist) assert next(watchlist) == Movie("Moana", 2016) assert next(watchlist) == Movie("Your Name", 2016) assert next(watchlist) == Movie("A Silent Voice", 2016)
def test_getter(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Your Name", 2016)) watchlist.add_movie(Movie("A Silent Voice", 2016)) assert watchlist.watchlist == [ Movie("Moana", 2016), Movie("Your Name", 2016), Movie("A Silent Voice", 2016) ]
def read_csv_file(self): with open(self.__file_name, mode='r', encoding='utf-8-sig') as csvfile: movie_file_reader = csv.DictReader(csvfile) index = 0 for row in movie_file_reader: add_rank = row['Rank'] add_title = row['Title'] add_year = int(row['Year']) add_description = row['Description'] add_actors = [] add_genres = [] add_director = "" actors_list = row['Actors'].split(",") for a in actors_list: actor = a.strip() add_actor = Actor(actor) if add_actor not in self._dataset_of_actors: self._dataset_of_actors.append(add_actor) add_actors.append(add_actor) directors_list = row['Director'].split(",") for d in directors_list: add_director = Director(d) if add_director not in self._dataset_of_directors: self._dataset_of_directors.append(add_director) add_director = d genre_list = row['Genre'].split(",") for g in genre_list: add_genre = Genre(g) if add_genre not in self._dataset_of_genres: self._dataset_of_genres.append(add_genre) add_genres.append(add_genre) add_movie = Movie(add_title, add_year, add_rank, add_description, add_director, add_actors, add_genres) self._dataset_of_movies.append(add_movie) index += 1
def read_csv_file(self): with open(self.__file_name, mode='r', encoding='utf-8-sig') as csvfile: movie_file_reader = csv.DictReader(csvfile) for row in movie_file_reader: title = row['Title'] release_year = int(row['Year']) description = row['Description'] time = int(row['Runtime (Minutes)']) movie = Movie(title, release_year) actors1 = row['Actors'].split(",") actors2 = [] for i in actors1: actors2.append(Actor(i)) director = Director(row['Director']) genres1 = row['Genre'].split(",") genres2 = [] for i in genres1: genres2.append(Genre(i)) movie.director = director movie.description = description movie.actors = actors2 movie.genres = genres2 movie.runtime_minutes = time #Adding to datasets self.__dataset_of_movies.append(movie) for actor in actors2: self.__dataset_of_actors.add(actor) self.__dataset_of_directors.add(director) for genre in genres2: self.__dataset_of_genres.add(genre)
def test_select_movie_to_watch_index_out_of_bounds(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Your Name", 2016)) watchlist.add_movie(Movie("A Silent Voice", 2016)) assert watchlist.select_movie_to_watch(3) == None
def test_select_movie_to_watch_index(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Your Name", 2016)) watchlist.add_movie(Movie("A Silent Voice", 2016)) assert watchlist.select_movie_to_watch(1) == Movie("Your Name", 2016)
def test_remove_movie_which_is_not_in_watchlist(watchlist): watchlist.add_movie(Movie("Moana", 2016)) assert watchlist.remove_movie(Movie("Your Name", 2016)) == None assert watchlist.size() == 1
def test_remove_movie(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Your Name", 2016)) watchlist.remove_movie(Movie("Moana", 2016)) assert watchlist.size() == 1 assert watchlist.first_movie_in_watchlist() == Movie("Your Name", 2016)
def test_watch_movie(self, usergroup): mov = Movie("Moana", 2016) mov.runtime_minutes = 20 usergroup.watch_movie(mov) for user in usergroup.members: assert user.time_spent_watching_movies_minutes == 20
def test_add_movie(watchlist): watchlist.add_movie(Movie("Moana", 2016)) assert watchlist.first_movie_in_watchlist() == Movie("Moana", 2016)
def test_check_size_of_nonempty_watchlist(watchlist): watchlist.add_movie(Movie("Moana", 2016)) assert watchlist.size() == 1
def test_see_friend_reviews(user, friend): user.send_friend_request(friend) friend.accept_pending_request(user) thisisareview = Review(Movie("Garlic Bread", 2020), "this is a review.", 9) friend.add_review(thisisareview) assert user.see_friend_reviews(friend) == [thisisareview]
def test_add_movie(self, watchlist): movie = Movie("Moana", 2016) watchlist.add_movie(movie) assert watchlist.first_movie_in_watchlist() == movie
def test_repository_can_add_movie(in_memory_repo): movie = Movie("Arrivaz", 2020) in_memory_repo.add_movie(movie) assert in_memory_repo.get_movie(31) is movie
def test_add_same_movie_again(watchlist): watchlist.add_movie(Movie("Moana", 2016)) watchlist.add_movie(Movie("Moana", 2016)) assert watchlist.size() == 1
def test_next(self, watchlist): movie = Movie("Moana", 2016) watchlist.add_movie(movie) assert next(watchlist) == movie with pytest.raises(StopIteration): next(watchlist)
def movie(self): """ """ return Movie("Moana", 2016)