def test_accessing_non_friend(user, friend): thisisamovie = Movie("Garlic Bread", 2020) thisisareview = Review(thisisamovie, "this is a review.", 9) thisisamovie.runtime_minutes = 69 friend.watch_movie(Movie("Garlic Bread", 2020), 35) friend.add_review(thisisareview) assert user.see_friend_watched_movies(friend) is None assert user.see_friend_reviews(friend) is None assert user.see_friend_minutes_watched(friend) is None
def test_repository_does_not_add_a_review_without_an_movie_properly_attached( in_memory_repo): user = in_memory_repo.get_user('thorke') movie = in_memory_repo.get_movie(2) review = Review(movie, "i love movie hehe xd", 9) user.add_review(review) with pytest.raises(RepositoryException): # Exception expected because the movie doesn't refer to the review. in_memory_repo.add_review(review)
def test_repository_does_not_add_a_review_without_a_movie_properly_attached( in_memory_repo): user = User('Ella', '123456789') in_memory_repo.add_user(user) user = in_memory_repo.get_user('Ella') movie = in_memory_repo.get_movie(2) review = Review(None, movie, "Could be better", 3, datetime.today()) user.add_review(review) with pytest.raises(RepositoryException): # Exception expected because the Movie doesn't refer to the Review. in_memory_repo.add_review(review)
def test_add_review(self, user, movie): review = Review(movie, user, "good movies", 8) user.add_review(review) assert user.reviews == [review]
def test_repository_does_not_add_a_review_without_a_user(in_memory_repo): movie = in_memory_repo.get_movie(1) review = Review(movie, "i love movie hehe xd", 9) with pytest.raises(RepositoryException): in_memory_repo.add_review(review)
def add_review(movie_id, review_txt, username): # movie_list = repo.repo_instance.get_movies() movie = get_movie(movie_id) review = Review(movie, review_txt, username) movie.add_review(review) repo.repo_instance.update_movie_review(movie, review)
def test_see_friend_reviews(user, friend): user.send_friend_request(friend) friend.accept_pending_request(user) thisisareview = Review(Movie("Garlic Bread", 2020), "this is a review.", 9) friend.add_review(thisisareview) assert user.see_friend_reviews(friend) == [thisisareview]
def review(self): """ """ return Review(Movie('Moana', 2016), None,'This Movie was really good', 10)
def test_repository_does_not_add_a_review_without_a_user(in_memory_repo): movie = in_memory_repo.get_movie(2) review = Review(None, movie, "Could be better", 3, datetime.today()) with pytest.raises(RepositoryException): in_memory_repo.add_review(review)
def test_rating(self, review): assert review.rating == 10 assert Review(Movie('Moana', 2016),None, 'This Movie was really good', 'a').rating is None
def test_review_text(self, review): assert review.review_text == 'This Movie was really good' assert Review(Movie('Moana', 2016), None,10, 9).review_text is None
def test_movie(self, review): assert review.movie == Movie('Moana', 2016) assert Review('a',None, 'good movies', 8).movie is None
def test_eq(self, review): assert review != Review(Movie('Moana', 2016), None, 'This Movie was really good', 10)
def test_repo_wont_add_invalid_review(in_memory_repo): with pytest.raises(RepositoryException): in_memory_repo.add_review(Review(None, None, 2345, 'a'))