def test_watchlist_add_several():
    watchlist = WatchList()
    #print(f"Size of watchlist: {watchlist.size()}")
    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))
    #print(watchlist.first_movie_in_watchlist())
    assert repr(watchlist.first_movie_in_watchlist()) == "<Movie Moana, 2016>"
def test_watchlist_first_movie_valid():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    #print(watchlist.first_movie_in_watchlist())
    assert repr(watchlist.first_movie_in_watchlist()) == "<Movie Moana, 2016>"
def test_watchlist_size():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    #print(watchlist.size())
    assert watchlist.size() == 3
def test_watchlist_invalid_select():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    #print(watchlist.select_movie_to_watch(3))
    assert watchlist.select_movie_to_watch(3) == None
def test_watchlist_valid_select():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    #print(watchlist.select_movie_to_watch(1))
    assert repr(watchlist.select_movie_to_watch(1)) == "<Movie Ice Age, 2002>"
def test_watchlist_remove_movie_not_in_watchlist():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.remove_movie(Movie("Guardians of the Galaxy", 2012))
    watchlist_iter = iter(watchlist)

    #print(next(watchlist_iter))
    #print(next(watchlist_iter))

    assert repr(next(watchlist_iter)) == "<Movie Moana, 2016>"
    assert repr(next(watchlist_iter)) == "<Movie Ice Age, 2002>"
def test_watchlist_iter_invalid():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))

    watchlist_iter = iter(watchlist)
    while True:
        try:
            result = next(watchlist_iter)
        except StopIteration:
            assert True
            break
def test_watchlist_add_same_movie():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist_iter = iter(watchlist)

    #print(next(watchlist_iter))
    #print(next(watchlist_iter))

    assert repr(next(watchlist_iter)) == "<Movie Moana, 2016>"
    assert repr(next(watchlist_iter)) == "<Movie Ice Age, 2002>"
    try:
        next(watchlist_iter)
    except StopIteration:
        assert True
def test_watchlist_first_movie_invalid():
    watchlist = WatchList()
    #print(watchlist.first_movie_in_watchlist())
    assert watchlist.first_movie_in_watchlist() == None
Exemple #10
0
def watchlist():
    return WatchList()
 def get_user_watch_list(self, user):
     if user not in self.__user_watch_list.keys():
         self.__user_watch_list[user] = WatchList()
     return self.__user_watch_list[user]
 def add_user_watch_list(self, user, movie):
     if user not in self.__user_watch_list.keys():
         self.__user_watch_list[user] = WatchList()
     self.__user_watch_list[user].add_movie(movie)