def test_add_and_get_genres(session_factory):
    repository = SqlAlchemyRepository(session_factory)
    repository.add_genre(Genre("Japanese Anime"))
    repository.add_genre(Genre("Japanese Anime"))
    repository.add_genre(Genre("Emotional"))
    genres = repository.get_genres()
    assert Genre("Emotional") in genres and Genre("Japanese Anime") in genres
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) == []
def test_repository_can_add_a_genre(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    genre = Genre('Motoring')
    genre.tagged_movies = None
    repo.add_genre(genre)

    assert genre in repo.get_genres()
Example #4
0
def test_repository_can_add_genre(session_factory):
    repo = SqlAlchemyRepository(session_factory)
    genre = Genre('Indie')
    repo.add_genre(genre)
    assert genre in repo.get_genres()