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)
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)
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 __init__(self, username: str, password: str): self.__username = username.strip().lower() self.__password = password self.__watched_movies = [] self.__reviews = [] self.__time_spent_watching_movies_minutes = 0 self.__watch_list = WatchList()
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 watchlist(): return WatchList()
def test_remove_movie(watchlist): watchlist = WatchList() watchlist.add_movie(Movie("Moana", 2016)) watchlist.remove_movie(Movie("Moana", 2016)) assert watchlist.size() == 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
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