Esempio n. 1
0
def test_remove():
    watchlist = WatchList()
    watchlist.remove_movie(Movie("Moana", 2016))

    assert watchlist.size() == 0

    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.remove_movie(Movie("Moana", 2016))

    assert watchlist.size() == 0
Esempio n. 2
0
def test_add():
    watchlist = WatchList()
    watchlist.add_movie("hello world")

    assert watchlist.size() == 0

    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))

    assert watchlist.size() == 1
Esempio n. 3
0
def test_selection():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Avengers: Endgame", 2019))

    assert watchlist.select_movie_to_watch(1) == Movie("Avengers: Endgame",
                                                       2019)

    assert watchlist.select_movie_to_watch(2) == None
Esempio n. 4
0
def test_iteration():
    watchlist = WatchList()
    movies = [
        Movie("Moana", 2016),
        Movie("Avengers: Endgame", 2019),
        Movie("Ladybird", 2017)
    ]
    for movie in movies:
        watchlist.add_movie(movie)
    iterator = iter(watchlist)

    assert next(iterator) == Movie("Moana", 2016)
    assert next(iterator) == Movie("Avengers: Endgame", 2019)
    assert next(iterator) == Movie("Ladybird", 2017)

    with pytest.raises(StopIteration):
        next(iterator)
Esempio n. 5
0
def test_repeated_add():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Moana", 2016))
    assert watchlist.size() == 1
Esempio n. 6
0
def watchlist():
    return WatchList()
Esempio n. 7
0
def test_first_select():
    watchlist = WatchList()
    watchlist.add_movie(Movie("Moana", 2016))

    assert watchlist.first_movie_in_watchlist() == Movie("Moana", 2016)