Exemple #1
0
def test_can_add_comment(in_memory_repo):
    movie_id = 3
    review_text = 'This is a good movie to see with your friends'
    username = '******'
    print(in_memory_repo.get_movie_by_id(movie_id))
    # Call the service layer to add the comment.
    review = Review(in_memory_repo.get_movie_by_id(movie_id), review_text, 7,
                    in_memory_repo.get_user(username))
    services.add_review(in_memory_repo, review_text,
                        in_memory_repo.get_movie_by_id(movie_id), 7,
                        in_memory_repo.get_user(username))

    # Retrieve the comments for the article from the repository.
    review_as_list = services.get_reviews(in_memory_repo, movie_id)

    # Check that the comments include a comment with the new comment text.
    assert next(
        (review_element
         for review_element in review_as_list if review_element == review),
        None) is not None
Exemple #2
0
def get_reviews(movie_id: int):
    return services.get_reviews(repo.repo_instance, movie_id)
Exemple #3
0
def test_get_comments_for_non_existent_article(in_memory_repo):
    with pytest.raises(services.NonExistentMovieException):
        review_as_list = services.get_reviews(in_memory_repo, 1002)
Exemple #4
0
def test_get_comments_for_article_without_comments(in_memory_repo):
    reviews_as_list = services.get_reviews(in_memory_repo, 5)
    assert len(reviews_as_list) == 0
Exemple #5
0
def test_get_review_for_movie(in_memory_repo):
    review_as_list = services.get_reviews(in_memory_repo, 1)

    # Check that 3 comments were returned for movie with id 1.
    assert len(review_as_list) == 3