Exemple #1
0
def test_given(watchlist):
    watchlist = WatchList()
    assert watchlist.size() == 0
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert watchlist.first_movie_in_watchlist() == Movie("Moana", 2016)
Exemple #2
0
def test_select_movie_to_watch(watchlist):
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert watchlist.select_movie_to_watch(2) == Movie(
        "Guardians of the Galaxy", 2012)
Exemple #3
0
def test_iterator(watchlist):
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    temp = iter(watchlist)
    assert next(temp) == Movie("Moana", 2016)
def test_2():
    name = User("Banana", "abcd1234")
    movie = Movie("Moviename", 2020)
    movie.runtime_minutes = 100
    name.watch_movie(movie)
    name.add_review("123")
    name.watch_list.add_movie(movie)
    assert name.watched_movies == [movie]
    assert name.watch_list.movie_list == [movie]
    assert name.reviews == ["123"]
    assert name.time_spent_watching_movies_minutes == 100
Exemple #5
0
def test_iterator_out_of_bound(watchlist):
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    temp = iter(watchlist)
    next(temp)
    next(temp)
    next(temp)
    with pytest.raises(StopIteration):
        next(temp)
def test_given(movie):
    movie = Movie("Moana", 2016)
    assert movie == Movie("Moana", 2016)

    director = Director("Ron Clements")
    movie.director = director
    assert movie.director == Director("Ron Clements")

    actors = [
        Actor("Auli'i Cravalho"),
        Actor("Dwayne Johnson"),
        Actor("Rachel House"),
        Actor("Temuera Morrison")
    ]
    for actor in actors:
        movie.add_actor(actor)
    assert movie.actors == actors

    movie.runtime_minutes = 107
    assert movie.runtime_minutes == 107
def test_votes(movie):
    movie = Movie("Moana", 2016)
    movie.votes = 12345
    assert movie.votes == 12345
def test_rating_type(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.rating = "banana"
def test_metascore(movie):
    movie = Movie("Moana", 2016)
    movie.metascore = 93
    assert movie.metascore == 93
def test_revenue_millions_out_of_bounds(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.revenue_millions = -1
def movie():
    return Movie("Moana", 2016)
Exemple #12
0
    def read_csv_file_movies(self):
        with open(self.__file_name, mode='r', encoding='utf-8-sig') as csvfile:
            self.dataset_of_movies = []
            movie_file_reader = csv.DictReader(csvfile)
            index = 0
            for row in movie_file_reader:
                movie = Movie(row["Title"], int(row["Year"]))
                movie.description = row["Description"]
                movie.runtime_minutes = int(row["Runtime (Minutes)"])
                if row["Rating"] != "N/A":
                    movie.rating = float(row['Rating'])
                if row["Votes"] != "N/A":
                    movie.votes = int(row["Votes"])
                if row["Revenue (Millions)"] != "N/A":
                    movie.revenue_millions = float(row["Revenue (Millions)"])
                if row["Metascore"] != "N/A":
                    movie.metascore = int(row["Metascore"])
                for director in self.__dataset_of_directors:
                    if director.director_full_name == row["Director"]:
                        movie.director = director

                temp_actor_list = []
                for actor in row["Actors"].split(","):
                    temp_actor_list.append(actor.strip())

                temp_genre_list = []
                for genre in row["Genre"].split(","):
                    temp_genre_list.append(genre.strip())

                for actor in self.__dataset_of_actors:
                    if actor.actor_full_name in temp_actor_list:
                        movie.add_actor(actor)

                for genre in self.__dataset_of_genres:
                    if genre.genre_name in temp_genre_list:
                        movie.add_genre(genre)
                index += 1
                self.dataset_of_movies.append(movie)
Exemple #13
0
def test_remove_movie(watchlist):
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.remove_movie(Movie("Moana", 2016))
    assert watchlist.size() == 0
Exemple #14
0
def test_remove_moive_not_in_list(watchlist):
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.remove_movie(Movie("Ice Age", 2002))
    assert watchlist.size() == 1
Exemple #15
0
def test_size(watchlist):
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert watchlist.size() == 3
def test_votes_out_of_bounds(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.votes = -1
def test_votes_type(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.votes = 1234.5
Exemple #18
0
 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:
             movie = Movie(row["Title"], int(row["Year"]))
             movie.description = row["Description"]
             movie.runtime_minutes = int(row["Runtime (Minutes)"])
             self.__total_runtime_minutes += int(row["Runtime (Minutes)"])
             self.__runtime_minutes_number_of_movies += 1
             if row["Rating"] != "N/A":
                 movie.rating = float(row['Rating'])
                 self.__total_rating += float(row['Rating'])
                 self.__rating_number_of_movies += 1
             if row["Votes"] != "N/A":
                 movie.votes = int(row["Votes"])
                 self.__total_votes += int(row["Votes"])
                 self.__votes_number_of_movies += 1
             if row["Revenue (Millions)"] != "N/A":
                 movie.revenue_millions = float(row["Revenue (Millions)"])
                 self.__total_revenue_millions += float(
                     row["Revenue (Millions)"])
                 self.__revenue_millions_number_of_movies += 1
             if row["Metascore"] != "N/A":
                 movie.metascore = int(row["Metascore"])
                 self.__total_metascore += int(row["Metascore"])
                 self.__metascore_number_of_movies += 1
             movie.director = Director(row["Director"])
             self.__dataset_of_directors.add(Director(row["Director"]))
             for actor in row["Actors"].split(","):
                 movie.add_actor(Actor(actor.strip()))
                 self.__dataset_of_actors.add(Actor(actor.strip()))
             for genre in row["Genre"].split(","):
                 movie.add_genre(Genre(genre.strip()))
                 self.__dataset_of_genres.add(Genre(genre.strip()))
             index += 1
             self.__dataset_of_movies.append(movie)
def test_revenue_millions(movie):
    movie = Movie("Moana", 2016)
    movie.revenue_millions = 123.45
    assert movie.revenue_millions == 123.45
def test_metascore_type(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.metascore = 93.3
def test_revenue_millions_type(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.revenue_millions = "banana"
def test_rating(movie):
    movie = Movie("Moana", 2016)
    movie.rating = 9.5
    assert movie.rating == 9.5
def test_metascore_out_of_bounds_lower(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.metascore = -1
def test_rating_out_bounds_upper(movie):
    movie = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie.rating = 10.5
Exemple #25
0
def test_search_title_fuzzy3(memory_repository):
    assert memory_repository.get_movie_title("the avengerss") == [
        Movie("The Avengers", 2012)
    ]
Exemple #26
0
def test_search_title_fuzzy3():
    filename = 'movie_web_app/adapters/Data1000Movies.csv'
    file_reader = MovieFileCSVReader(filename)
    assert file_reader.get_movie_title("the avengerss") == [Movie("The Avengers", 2012)]