def test_repository_can_retrieve_movie_count(session_factory): repo = SqlAlchemyRepository(session_factory) number_of_movies = repo.get_number_of_movies() # Check that the query returned 10 Movies. assert number_of_movies == 10
def test_get_number_of_movies(session_factory): repository = SqlAlchemyRepository(session_factory) initial_length = repository.get_number_of_movies() movie1 = Movie("Maquia", 2018) movie2 = Movie("Ice Age", 2002) 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 repository.add_movie(movie1) assert repository.get_number_of_movies() == initial_length + 1 repository.add_movie(movie2) assert repository.get_number_of_movies() == initial_length + 2
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
def test_repository_can_retrieve_movie_count(session_factory): repo = SqlAlchemyRepository(session_factory) count = repo.get_number_of_movies() assert count == 1000