Beispiel #1
0
 def test_remove(self, watchlist):
     assert watchlist.size() == 2
     watchlist.remove_movie(Movie("Movie1", 2001))
     assert watchlist.size() == 1
     assert watchlist.first_movie_in_watchlist() == Movie("Movie2", 2019)
     watchlist.remove_movie(Movie("Movie2", 2019))
     assert watchlist.first_movie_in_watchlist() is None
Beispiel #2
0
 def test_add_redundant_movie(self):
     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.add_movie(Movie("Moana", 2016))
     assert watchlist.size == 3
Beispiel #3
0
def test_name():
    assert Movie("  ", 2010).title is None

    assert Movie("Plagueis the Wise?", 2010).title == "Plagueis the Wise?"

    m = Movie("  I thought not.   ", 2010)
    assert m.title == "I thought not."
Beispiel #4
0
def test_lt_same_name_same_year():
    movie1 = Movie("Spirited Away", 2000)
    movie2 = Movie("Spirited Away", 2000)
    lt = movie1 < movie2
    eq = movie1 == movie2
    assert eq == True
    assert lt == False
Beispiel #5
0
def test_create_watch_list():
    watchlist = WatchList()
    assert (f"Size of watchlist: {watchlist.size()}") == f"Size of watchlist: 0"
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert str(watchlist.first_movie_in_watchlist()) == '<Movie Moana, 2016>'
Beispiel #6
0
def test_lt_none_name2_same_year():
    movie1 = Movie("Spirited Away", 2008)
    movie2 = Movie(None, 2008)
    lt = movie1 < movie2
    eq = movie1 == movie2
    assert eq == False
    assert lt == False
Beispiel #7
0
def test_eq_same_name_same_year():
    movie1 = Movie("Spirited Away", 2000)
    movie2 = Movie("Spirited Away", 2000)
    equal = movie1 == movie2
    eq = movie1 == movie2
    assert eq == True
    assert equal == True
def test_select_movie_to_watch_index_ok():
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Mulan", 2020)
    watchlist1 = WatchList()
    watchlist1.add_movie(movie1)
    watchlist1.add_movie(movie2)
    assert watchlist1.select_movie_to_watch(1) == Movie("Mulan", 2020)
def test_select_movie_to_watch_index_out_of_bounds_negative():
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Mulan", 2020)
    watchlist1 = WatchList()
    watchlist1.add_movie(movie1)
    watchlist1.add_movie(movie2)
    assert watchlist1.select_movie_to_watch(-1) == None
def test_remove_movie_which_is_not_in_watchlist():
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Mulan", 2020)
    watchlist1 = WatchList()
    watchlist1.add_movie(movie1)
    watchlist1.remove_movie(movie2)
    assert watchlist1.size() == 1
def test_check_size():
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Mulan", 2020)
    watchlist1 = WatchList()
    watchlist1.add_movie(movie1)
    watchlist1.add_movie(movie2)
    assert watchlist1.size() == 2
def test_first_movie_in_watchlist():
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Mulan", 2020)
    watchlist1 = WatchList()
    watchlist1.add_movie(movie1)
    watchlist1.add_movie(movie2)
    assert watchlist1.first_movie_in_watchlist() == Movie("Moana", 2016)
Beispiel #13
0
def test_select_movie_to_watch(watchlist):
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert repr(watchlist.select_movie_to_watch(0)) == "<Movie Moana, 2016>"
    assert watchlist.select_movie_to_watch(-1) is None
    assert watchlist.select_movie_to_watch(3) is None
Beispiel #14
0
 def test_remove_movie(self, watchlist):
     movie1 = Movie("The 100", 2016)
     movie2 = Movie("Bones", 2004)
     watchlist.add_movie(movie1)
     watchlist.add_movie(movie2)
     watchlist.remove_movie(movie2)
     assert watchlist.size() == 1
Beispiel #15
0
def test_lt_diff_name_none_year_2():
    movie1 = Movie("Spirited Away", 2008)
    movie2 = Movie("Spirited", 1750)
    lt = movie1 < movie2
    eq = movie1 == movie2
    assert eq == False
    assert lt == False
Beispiel #16
0
 def test_watched_movies(self):
     user1 = User('user1', 'pw12345')
     movie1 = Movie("Star War", 19879)
     movie1.runtime_minutes = 120
     user1.watch_movie(movie1)
     assert user1.watched_movies == [movie1]
     assert user1.time_spent_watching_movies_minutes == 120
Beispiel #17
0
def test_lt_same_name_none_year_1():
    movie1 = Movie("Spirited Away", 1550)
    movie2 = Movie("Spirited Away", 2008)
    lt = movie1 < movie2
    eq = movie1 == movie2
    assert eq == False
    assert lt == True
Beispiel #18
0
def test_hash_two_movie():
    a_set = set()
    movie1 = Movie("Moana", 2016)
    movie2 = Movie("Kung fu Panda", 2019)
    a_set.add(movie1)
    a_set.add(movie2)
    assert len(a_set) == 2
Beispiel #19
0
def test_lt_same_name_none_year_both():
    movie1 = Movie("Spirited Away", None)
    movie2 = Movie("Spirited Away", None)
    lt = movie1 < movie2
    eq = movie1 == movie2
    assert eq == True
    assert lt == False
Beispiel #20
0
def test_init():
    movie1 = Movie("Moana", 2016)
    assert repr(movie1) == "<Movie Moana, 2016>"
    movie1.director(Director("Ron Clements"))
    assert "<Director Ron Clements>"
    movie2 = Movie("Kung fu Panda", 1821)
    assert repr(movie2) == "<Movie Kung fu Panda, None>"
Beispiel #21
0
def test_eq_diff_name_diff_year():
    movie1 = Movie("Spirited Away", 2000)
    movie2 = Movie("Spirited", 2005)
    equal = movie1 == movie2
    eq = movie1 == movie2
    assert eq == False
    assert equal == False
Beispiel #22
0
 def test_iter(self):
     watchlist = WatchList()
     watchlist.add_movie(Movie("Moana", 2016))
     watchlist.add_movie(Movie("Ice Age", 2002))
     i = iter(watchlist)
     assert next(watchlist) == Movie("Moana", 2016)
     assert next(watchlist) == Movie("Ice Age", 2002)
Beispiel #23
0
def test_check_size():
    watchlist = WatchList()
    assert (f"Size of watchlist: {watchlist.size()}") == f"Size of watchlist: 0"
    watchlist.add_movie(Movie("Moana", 2016))
    watchlist.add_movie(Movie("Ice Age", 2002))
    watchlist.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert (f"Size of watchlist: {watchlist.size()}") == f"Size of watchlist: 3"
Beispiel #24
0
 def test_remove(self):
     watchlist = WatchList()
     watchlist.add_movie(Movie("Moana", 2016))
     watchlist.add_movie(Movie("Ice Age", 2002))
     assert watchlist.size() == 2
     watchlist.remove_movie(Movie("Ice Age", 2002))
     assert watchlist.size() == 1
Beispiel #25
0
def test_see_friend_minutes_watched(user, friend):
    user.send_friend_request(friend)
    friend.accept_pending_request(user)
    thisisamovie = Movie("Garlic Bread", 2020)
    thisisamovie.runtime_minutes = 69
    friend.watch_movie(thisisamovie)
    assert user.see_friend_minutes_watched(friend) == 69
Beispiel #26
0
def constructor_test():
    watchlist = WatchList()
    print(watchlist.size())
    watchlist.add_movie(Movie("Up", 2009))
    print(watchlist.size())
    watchlist.add_movie(Movie("Down", 1999))
    print(watchlist.size())
    watchlist.add_movie(Movie("XYZ", 2013))
    print(watchlist.size())
    watchlist.add_movie(Movie("Anabelle", 2020))
    print(watchlist.size())
    watchlist.add_movie(Movie("Anabelle", 2020))
    print(watchlist.size())

    i = iter(watchlist)
    print(next(i))
    print(next(i))
    print(next(i))

    for movie in i:
        print(movie)

    watchlist.remove_movie(Movie("Up", 2009))
    print(watchlist.size())
    watchlist.remove_movie(Movie("Left", 2009))
    print(watchlist.size())
    print(watchlist.select_movie_to_watch(0))
    print(watchlist.select_movie_to_watch(4))
    print(watchlist.first_movie_in_watchlist())
    watchlist.remove_movie(Movie("Down", 1999))
    watchlist.remove_movie(Movie("XYZ", 2013))
    watchlist.remove_movie(Movie("Anabelle", 2020))
    print(watchlist.first_movie_in_watchlist())
Beispiel #27
0
 def test_first_movie_in_watchlist(self):
     watchlist = WatchList()
     movie1 = Movie("Moana", 2016)
     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() == movie1
Beispiel #28
0
def test_lt_diff_name_diff_year():
    movie1 = Movie("Spirited Away", 2000)
    movie2 = Movie("Spirited", 2008)
    lt = movie1 < movie2
    eq = movie1 == movie2
    assert eq == False
    assert lt == False
 def test_change_movie(self, watching_session):
     user1 = User("Aidan", "Wasx")
     user2 = User("Iona", "Mort")
     watching_session.change_movie(user2, Movie("Lion King", 2019))
     assert watching_session.watching == Movie("Cars", 2008)
     watching_session.change_movie(user1, Movie("Lion King", 2019))
     assert watching_session.watching == Movie("Lion King", 2019)
Beispiel #30
0
    def test_least_watched(self):
        user1 = User("John", "abc123")
        user2 = User("Mike", "abcd123")
        user3 = User("Sam", "bebebebe")

        movie1 = Movie("Moana", 2016)
        movie2 = Movie("Ice Age", 2002)
        movie3 = Movie("John Cena", 1999)
        movie4 = Movie("Bravo", 2000)
        movie5 = Movie("Charlie", 1987)

        user1.watch_movie(movie1)

        user1.watch_movie(movie2)
        user1.watch_movie(movie2)
        user1.watch_movie(movie2)
        user1.watch_movie(movie2)
        user1.watch_movie(movie2)
        user2.watch_movie(movie2)

        user2.watch_movie(movie3)
        user3.watch_movie(movie3)

        lst = [movie1, movie2, movie3, movie4, movie5]

        film_comparison = movie_compare(lst)
        film_comparison.least_watched()

        assert film_comparison.movies_lst == [
            movie4, movie5, movie1, movie3, movie2
        ]