예제 #1
0
def test_write_review_for_everyone(simulation):
    u1 = User('X', '123456')
    simulation.add_user(u1)
    r1 = Review(Movie('WOW', 2020), "A very good movie", 10)
    simulation.write_review_for_everyone(r1)
    assert len(simulation.administrator.reviews) == 1
    assert u1.reviews[0].movie == Movie('WOW', 2020)
예제 #2
0
def test_share_watchlist(w):
    w.add_movie(Movie("Moana", 2016))
    w.add_movie(Movie("Ice Age", 2002))
    w.add_movie(Movie("Guardians of the Galaxy", 2012))
    user1 = User("DEF", "wow")
    w1 = w.share_watchlist(user1)
    assert w1.watchlist_owner == user1
    assert w1.watchlist == w.watchlist
예제 #3
0
def test_sort_by_year(w):
    m1 = Movie("Moana", 2016)
    m2 = Movie("Ice Age", 2002)
    m3 = Movie("Guardians of the Galaxy", 2012)
    w.add_movie(m1)
    w.add_movie(m2)
    w.add_movie(m3)
    watchlist = w.sort_watchlist_by_year()
    assert watchlist == [m2, m3, m1]
예제 #4
0
def make_movie():
    movie = Movie("WOW", 2020)
    movie.rank = 1001
    movie.description = "This is the best movie in the world."
    movie.director = Director("Barraza")
    movie.runtime_minutes = 100
    movie.rating = 100
    movie.votes = 100
    movie.revenue = 100
    movie.metascore = 100
    return movie
예제 #5
0
def test_update_user_information(simulation):
    u1 = User('X', '123456')
    u2 = User('Y', '00000')
    simulation.add_user(u1)
    simulation.add_user(u2)
    m1 = Movie("NEW", 2021)
    m1.runtime_minutes = 100
    simulation.change_movie(m1)
    simulation.update_user_information()
    assert len(simulation.administrator.watched_movies) == 1
    assert u1.watched_movies[0] == m1
    assert u2.time_spent_watching_movies_minutes == 100
예제 #6
0
def test_sort_by_runtime(w):
    m1 = Movie("Moana", 2016)
    m2 = Movie("Ice Age", 2002)
    m3 = Movie("Guardians of the Galaxy", 2012)
    m1.runtime_minutes = 1
    m2.runtime_minutes = 100
    m3.runtime_minutes = 10
    w.add_movie(m1)
    w.add_movie(m2)
    w.add_movie(m3)
    watchlist = w.sort_watchlist_by_runtime()
    assert watchlist == [m1, m3, m2]
def test_repo_can_add_movie(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    number_of_movies = repo.get_number_of_movies()

    new_movie_id = number_of_movies + 1

    movie = Movie("WOW", 2020)
    movie.rank = new_movie_id
    movie.description = "This is the best movie in the world."
    movie.director = Director("Barraza")
    movie.runtime_minutes = 100
    movie.rating = 100
    movie.votes = 100
    movie.revenue = 100
    movie.metascore = 100
    repo.add_movie(movie)

    assert repo.get_movie(new_movie_id) == movie
예제 #8
0
def test_watch_movie():
    user1 = User('Martin', 'pw12345')
    m1 = Movie("a", 2000)
    m2 = Movie("b", 2000)
    m1.runtime_minutes = 10
    m2.runtime_minutes = 20
    user1.watch_movie(m1)
    user1.watch_movie(m2)
    assert (user1.time_spent_watching_movies_minutes == 30)
    assert (user1.watched_movies == [m1, m2])
예제 #9
0
def simulation():
    return MovieWatchingSimulation(User('ABC', '123'), Movie("WOW", 2020))
예제 #10
0
def test_repo_can_add_movie(in_memory_repo):
    movie = Movie('New Movie', 2020)
    movie.rank = 1001
    in_memory_repo.add_movie(movie)
    assert in_memory_repo.get_movie(1001) == movie
예제 #11
0
def test_clear_watchlist(w):
    w.add_movie(Movie("Moana", 2016))
    w.add_movie(Movie("Ice Age", 2002))
    w.add_movie(Movie("Guardians of the Galaxy", 2012))
    w.clear_watchlist()
    assert w.watchlist == []
예제 #12
0
def dict_to_movie(dict):
    movie = Movie(dict.title, dict.release_year)
    movie.rank = dict.rank
    movie.description = dict.description
    movie.director = dict_to_director(dict.director)
    movie.actors = dict_to_actors(dict.actors)
    movie.genres = dict_to_genres(dict.genres)
    movie.runtime_minutes = dict.runtime_minutes
    movie.rating = dict.rating
    movie.votes = dict.votes
    movie.revenue = dict.revenue
    movie.metascore = dict.metascore
    return movie
예제 #13
0
def test_hash():
    m1 = Movie("wow", 2000)
    hash1 = hash("wow" + str(2000))
    assert (hash(m1) == hash1)
예제 #14
0
def test_movie_eq():
    m1 = Movie("wow", 0)
    m2 = Movie("wow", 1899)
    assert (m1 == m2)
예제 #15
0
def test_iter_and_next(w):
    w.add_movie(Movie("Moana", 2016))
    w.add_movie(Movie("Ice Age", 2002))
    w.add_movie(Movie("Guardians of the Galaxy", 2012))
    iterable = iter(w)
    assert next(iterable) == Movie("Moana", 2016)
예제 #16
0
def test_add_review():
    user1 = User('Martin', 'pw12345')
    m1 = Movie('a', 2000)
    r1 = Review(m1, 'wow', 10)
    user1.add_review(r1)
    assert (user1.reviews == [r1])
예제 #17
0
def test_repr():
    m1 = Movie("wow", 0)
    assert (repr(m1) == "<Movie wow, None>")
예제 #18
0
def test_change_movie(simulation):
    simulation.change_movie(Movie("NEW", 2021))
    assert simulation.movie_to_watch == Movie("NEW", 2021)
예제 #19
0
def test_add_actors():
    m1 = Movie("wow", 0)
    m1.actors = [Actor("a"), Actor("b"), Actor("c")]
    assert (m1.actors == [Actor("a"), Actor("b"), Actor("c")])
예제 #20
0
def test_add_and_remove_movie(w):
    w.add_movie(Movie("Moana", 2016))
    w.remove_movie(Movie("Moana", 2016))
    assert w.watchlist == []
예제 #21
0
def test_description():
    m1 = Movie("wow", 0)
    m1.description = ""
    assert (m1.description == "")
예제 #22
0
def test_movie_lt():
    m1 = Movie("", 0)
    m2 = Movie("x", 0)
    assert (m1 < m2)
예제 #23
0
def test_select_movie(w):
    w.add_movie(Movie("Moana", 2016))
    assert w.select_movie_to_watch(0) == Movie("Moana", 2016)
예제 #24
0
def test_set_title():
    m1 = Movie("wow", 0)
    m1.title = "WOW"
    assert (m1.title == "WOW")
예제 #25
0
def test_size(w):
    w.add_movie(Movie("Moana", 2016))
    assert w.size() == 1
예제 #26
0
def test_one_director():
    m1 = Movie("wow", 0)
    with pytest.raises(Exception):
        m1.director = [Director("a"), Director("b")]
예제 #27
0
def test_first_movie_in_watchlist(w):
    w.add_movie(Movie("Moana", 2016))
    w.add_movie(Movie("Ice Age", 2002))
    w.add_movie(Movie("Guardians of the Galaxy", 2012))
    assert w.first_movie_in_watchlist() == Movie("Moana", 2016)