コード例 #1
0
def test_repository_get_n_movies_with_offset(memory_repo):
    movie_3 = Movie("Movie3", 2002)
    movie_4 = Movie("Movie4", 2003)
    movies = memory_repo.get_n_movies(2, 2)
    assert len(movies) == 2
    assert movie_3 in movies
    assert movie_4 in movies
コード例 #2
0
def test_repository_get_n_movies(memory_repo):
    movie_1 = Movie("Movie1", 2000)
    movie_2 = Movie("Movie2", 2001)
    movies = memory_repo.get_n_movies(2, 0)
    assert len(movies) == 2
    assert movie_1 in movies
    assert movie_2 in movies
コード例 #3
0
ファイル: movie_reader.py プロジェクト: skim132/finals
    def read_csv_file(self):
        with open(self._data_path, mode='r', encoding='utf-8-sig') as f:
            records = csv.DictReader(f)
            for record in records:
                movie = Movie(record.get('Title'), int(record.get('Year', 0)))

                for actor in self._read_field(record, 'Actors', ','):
                    actor = Actor(actor)
                    movie.add_actor(actor)
                    self._dataset_of_actors.add(actor)

                for genre in self._read_field(record, 'Genre', ','):
                    genre = Genre(genre)
                    movie.add_genre(genre)
                    self._dataset_of_genres.add(genre)

                for director in self._read_field(record, 'Director', ','):
                    director = Director(director)
                    movie.set_director(director)
                    self._dataset_of_directors.add(director)

                movie.description = record.get('Description')
                movie.runtime_minutes = int(record.get('Runtime (Minutes)'))

                self._dataset_of_movies.add(movie)
コード例 #4
0
def test_remove_movie(watch_list):
    watch_list.add_movie(Movie("Passenger", 2016))
    watch_list.add_movie(Movie("avenger first solder", 2011))
    watch_list.add_movie(Movie("gravity", 2017))
    watch_list.remove_movie(Movie("avenger first solder", 2011))
    assert watch_list.size() == 2
    watch_list.remove_movie(Movie("Moana", 2017))
    assert watch_list.size() == 2
コード例 #5
0
def test_equal():
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Moana", 2016)
    movie3 = Movie("Moana", 2015)
    movie4 = Movie("Moana1", 2016)
    assert movie1 == movie2
    assert movie1 != movie3
    assert movie1 != movie4
コード例 #6
0
def test_set_director():
    movie1 = Movie("Passengers", 2016)
    director = Director("Director")
    movie1.director = director
    assert movie1.director == director
    director_invalid = "Director"
    movie1.director = director_invalid
    assert movie1.director == director
コード例 #7
0
def test_add_movie(watch_list):
    assert watch_list.size() == 0
    watch_list.add_movie(Movie("Passenger", 2016))
    watch_list.add_movie(Movie("avenger first solder", 2011))
    watch_list.add_movie(Movie("gravity", 2017))
    assert watch_list.size() == 3
    watch_list.add_movie(Movie("avenger first solder", 2011))
    assert watch_list.size() == 3
コード例 #8
0
def memory_repo():
    repo = memory_repository.MemoryRepository()
    movie_1 = Movie("Movie1", 2000)
    movie_2 = Movie("Movie2", 2001)
    movie_3 = Movie("Movie3", 2002)
    movie_4 = Movie("Movie4", 2003)
    movie_5 = Movie("Movie5", 2004)
    repo.add_movie(movie_1)
    repo.add_movie(movie_2)
    repo.add_movie(movie_3)
    repo.add_movie(movie_4)
    repo.add_movie(movie_5)
    return repo
コード例 #9
0
    def read_csv_file(self):
        try:
            TheCVS_file = open(self.file_name,
                               encoding='utf-8-sig',
                               newline='')
            to_reader = csv.DictReader(TheCVS_file)

            for All_row in to_reader:
                try:
                    movie = Movie(All_row['Title'].strip(),
                                  int(All_row['Year'].strip()))
                    actors = All_row['Actors'].split(',')

                    for num in range(len(actors)):
                        actors[num] = Actor(actors[num].strip())

                    split_rows = All_row['Genre'].split(',')
                    director = Director(All_row['Director'].strip())
                    genres = split_rows

                    for num in range(len(genres)):
                        genres[num] = Genre(genres[num].strip())

                    self.movies.append(movie)
                    self.actors.update(set(actors))

                    self.directors.add(director)
                    self.genres.update(set(genres))

                except:
                    continue

            TheCVS_file.close()

        except:
            raise Exception("Error while reading CSV file!")
コード例 #10
0
def test_delete_not_exist_movie(memory_repo):
    movie_not_exist = Movie('Not Existing Movie', 9999)
    res = memory_repo.delete_movie(movie_not_exist)
    assert res is False
    assert memory_repo.get_total_number_of_movies() == 5
コード例 #11
0
def test_set_title():
    movie_one = Movie("Passengers", 2016)
    movie_one.title = "Passengers"
    assert movie_one.title == "Passengers"
コード例 #12
0
def test_get_title():
    movie1 = Movie("Moana", 2016)
    assert movie1.title == "Moana"
コード例 #13
0
def test_delete_movie(memory_repo):
    movie_3 = Movie("Movie3", 2002)
    res = memory_repo.delete_movie(movie_3)
    assert res is True
    assert memory_repo.get_total_number_of_movies() == 4
コード例 #14
0
ファイル: test_review.py プロジェクト: skim132/finals
def movie2():
    return Movie("Moana2", 2016)
コード例 #15
0
def test_set_description():
    movie1 = Movie("Moana", 2016)
    movie1.description = "description"
    assert movie1.description == "description"
    movie1.description = ""
    assert movie1.description == "description"
コード例 #16
0
def test_repository_can_get_movie(memory_repo):
    movie = Movie('Test Movie', 2020)
    memory_repo.add_movie(movie)
    assert memory_repo.get_movie('test movie', 2020) is movie
コード例 #17
0
def test_set_runtime_minutes():
    movie1 = Movie("Passengers", 2016)
    with pytest.raises(ValueError):
        movie1.runtime_minutes = 0
コード例 #18
0
def test_set_year():
    movie1 = Movie("Moana", 2016)
    movie1.year = 2000
    assert movie1.year == 2000
    movie1.year = 1800
    assert movie1.year == 2000
コード例 #19
0
def test_get_year():
    movie1 = Movie("Moana", 2016)
    assert movie1.year == 2016
コード例 #20
0
def test_get_runtime_minutes():
    movie1 = Movie("Moana", 2016)
    movie1.runtime_minutes = 100
    assert movie1.runtime_minutes == 100
コード例 #21
0
def test_get_director():
    movie1 = Movie("Moana", 2016)
    assert movie1.director is None
コード例 #22
0
def test_init():
    movie = Movie("Moana", 2016)
    assert repr(movie) == "<Movie Moana, 2016>"
    movie = Movie("", 1899)
    assert movie.title is None
    assert repr(movie) == "<Movie None, None>"
コード例 #23
0
def test_get_director():
    movie1 = Movie("Passengers", 2016)
    assert movie1.director is None
コード例 #24
0
def test_repository_get_first_movie(memory_repo):
    movie_1 = Movie("Movie1", 2000)
    assert memory_repo.get_first_movie() == movie_1
コード例 #25
0
ファイル: test_review.py プロジェクト: skim132/finals
def movie():
    return Movie("Moana1", 2016)
コード例 #26
0
def test_repository_get_last_movie(memory_repo):
    movie_5 = Movie("Movie5", 2004)
    assert memory_repo.get_last_movie() == movie_5
コード例 #27
0
def test_init():
    movie_one = Movie("Passengers", 2016)
    assert repr(movie_one) == "<Movie Passengers, 2016>"
    movie_one = Movie("", 1899)
    assert movie_one.title is None
    assert repr(movie_one) == "<Movie None, None>"
コード例 #28
0
def test_set_title():
    movie1 = Movie("Moana", 2016)
    movie1.title = "Moana1"
    assert movie1.title == "Moana1"
コード例 #29
0
def test_repository_can_add_movie(memory_repo):
    movie = Movie('Test Movie', 2020)
    memory_repo.add_movie(movie)
    assert memory_repo.get_movie('test movie', 2020) is movie
    assert memory_repo.get_total_number_of_movies() == 6
コード例 #30
0
def test_get_description():
    movie1 = Movie("Moana", 2016)
    assert movie1.description is None