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
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
Exemple #3
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 #4
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)