def test_get_movies_by_genre(session_factory):
    repository = SqlAlchemyRepository(session_factory)
    movie1 = Movie("Maquia", 2018)
    movie2 = Movie("Ice Age", 2002)
    genre1 = Genre("Japanese Anime")
    genre2 = Genre("Emotional")
    repository.add_genre(genre1)
    repository.add_genre(genre2)
    movie1.description = "The Iorph people live far away from the world of humans, spending their days weaving " \
                         "Hibiol, a special cloth serving as a written chronicle every time. They age more slowly " \
                         "than humans and have the capacity to live for hundreds of years."
    movie1.runtime_minutes = 115
    movie2.description = "A Cronopio known as Scrat attempts to find a place to store his acorn for the winter. " \
                         "Eventually, as he tries to stomp it into the ground, he inadvertently causes a large " \
                         "crack to form in the ice that extends for miles before setting off a large avalanche " \
                         "which nearly crushes him."
    movie2.runtime_minutes = 81
    movie1.add_genre(genre1)
    movie1.add_genre(genre2)
    movie2.add_genre(genre2)
    repository.add_movie(movie1)
    repository.add_movie(movie2)
    assert repository.get_movies_by_genre("Japanese Anime") == [movie1]
    assert repository.get_movies_by_genre("xyz") == []
    assert repository.get_movies_by_genre("Emotional") == [movie2, movie1]
    assert repository.get_movies_by_genre(1) == []
Ejemplo n.º 2
0
def test_repository_does_not_add_a_review_without_a_user(session_factory):
    repo = SqlAlchemyRepository(session_factory)
    movie = Movie("Asdsa", 2014)
    movie.description = "Sam is sam he is"
    movie.director = Director('James')
    movie.runtime_minutes = 140
    repo.add_movie(movie)
    review = Review(None, movie, "Wow", 8, datetime.today())
    with pytest.raises(RepositoryException):
        repo.add_review(review)
Ejemplo n.º 3
0
def test_repository_can_add_a_movie(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    movie1 = Movie("Sam I am", 2000)
    movie1.description = "Sam is sam he is"
    movie1.director = Director('James')
    movie1.runtime_minutes = 140
    repo.add_movie(movie1)
    movie = repo.get_movie(1001)

    assert movie == Movie('Sam I am', 2000)
def test_repository_can_add_movie(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    number_of_movies = repo.get_number_of_movies()

    new_movie_rank = number_of_movies + 1

    movie = Movie('Wild Goose Lake', 2019, new_movie_rank)
    movie.genres = None
    movie.actors = None
    repo.add_movie(movie)

    assert repo.get_movie(new_movie_rank) == movie
Ejemplo n.º 5
0
def test_repository_can_add_a_review(session_factory):
    repo = SqlAlchemyRepository(session_factory)
    user = User('aidan', 'hi1234')
    movie = Movie("Asdsa", 2014)
    movie.description = "Sam is sam he is"
    movie.director = Director('James')
    movie.runtime_minutes = 140
    review = make_review("Wow good movie", user, movie, 9)

    repo.add_user(user)
    repo.add_movie(movie)
    repo.add_review(review)

    reviews = repo.get_reviews()
    assert len(reviews) == 1
    assert review in reviews
def test_add_and_get_movies(session_factory):
    repository = SqlAlchemyRepository(session_factory)
    maquia = Movie("Maquia", 2018)
    iceage = Movie("Ice Age", 2002)
    maquia.description = "The Iorph people live far away from the world of humans, spending their days weaving " \
                         "Hibiol, a special cloth serving as a written chronicle every time. They age more slowly " \
                         "than humans and have the capacity to live for hundreds of years."
    maquia.runtime_minutes = 115
    iceage.description = "A Cronopio known as Scrat attempts to find a place to store his acorn for the winter. " \
                         "Eventually, as he tries to stomp it into the ground, he inadvertently causes a large " \
                         "crack to form in the ice that extends for miles before setting off a large avalanche " \
                         "which nearly crushes him."
    iceage.runtime_minutes = 81
    repository.add_movie(maquia)
    repository.add_movie(iceage)
    repository.add_movie(iceage)
    assert repository.get_movie("Maquia", 2018) == Movie("Maquia", 2018)
    assert repository.get_movie("A Silent Voice", 2016) is None
    movies = repository.get_movies()
    assert Movie("Ice Age", 2002) in movies and Movie("Maquia", 2018) in movies