Beispiel #1
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])
Beispiel #2
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]
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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
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