def test_repository_can_add_and_get_review(session_factory): repo = SqlAlchemyRepository(session_factory) user = repo.get_user('asdfgh') movie = repo.get_movie("Moana") review_text = "This movie was very enjoyable." rating = 8 review = Review(movie, review_text, rating) repo.add_review(user, review) assert repo.get_review_by_user_and_id(user.user_name, review.reviewID, repo) is review
def test_repository_can_retrieve_review_by_user_and_id(session_factory): repo = SqlAlchemyRepository(session_factory) user1 = repo.get_user('asdfgh') user2 = repo.get_user('zxcvbn') movie1 = repo.get_movie("Fury") movie2 = repo.get_movie("Star Trek") review_text = "This movie was very enjoyable." rating = 8 review1 = Review(movie1, review_text, rating) review2 = Review(movie2, review_text, rating) review3 = Review(movie1, review_text, rating) review4 = Review(movie2, review_text, rating) review5 = Review(movie2, "meh", rating) repo.add_review(user1, review1) repo.add_review(user1, review2) repo.add_review(user2, review3) repo.add_review(user2, review4) repo.add_review(user2, review5) assert repo.get_review_by_user_and_id("asdfgh", 2, repo) == review2