def test_change_description():
    movie1 = Movie("Spirited Away", 2000)
    movie2 = Movie("Your Name", 2000)
    movie3 = Movie("Batman", 2000)
    movie4 = Movie(None, None)

    movie1.description = "Best movie"
    movie2.description = ""
    movie3.description = 123124124
    movie4.description = None

    assert movie1.description == "Best movie"
    assert movie2.description == ""
    assert movie3.description == ""
    assert movie4.description == ""
示例#2
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:
                # Read in Title
                title = row['Title']

                # Read in Year
                release_year = int(row['Year'])
                movie = Movie(title, release_year)
                self.__dataset_of_movies.append(movie)

                # Read in description
                description = row["Description"]
                movie.description = description

                # Read in runtime
                runtime = row["Runtime (Minutes)"]
                movie.runtime_minutes = int(runtime)

                # Read in Actors
                actors = row['Actors']
                actor = actors.split(",")
                for i in actor:
                    actor = i.strip()
                    movie.add_actor(Actor(actor))
                    self.__dataset_of_actors.add(Actor(actor))

                # Read in Directors
                director = row['Director']
                movie.director = Director(director)
                self.__dataset_of_directors.add(Director(director))

                # Read in Genre
                genres = row['Genre']
                genre = genres.split(",")
                for i in genre:
                    a = i.strip()
                    movie.add_genre(Genre(a))
                    self.__dataset_of_genres.add(Genre(a))

                # Read in Rank
                rank = row["Rank"]
                movie.rank = rank

                # Read in Rating
                rating = row["Rating"]
                movie.rating = rating

                # Read in Votes
                vote = row["Votes"]
                movie.votes = vote

                # Read in revenue
                revenue = row["Revenue (Millions)"]
                movie.revenue = revenue

                # Read in meta_scores
                metascore = row["Metascore"]
                movie.metascore = metascore

                index += 1