def test_repository_does_not_add_a_review_without_a_user(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    movie = repo.get_movie(2)
    user = repo.get_user('thorke')
    review = Review(user, movie, "Trump's onto it!", 5)

    with pytest.raises(RepositoryException):
        repo.add_review(review)
def test_repository_can_add_a_reviews(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    user = repo.get_user('thorke')
    movie = repo.get_movie(2)
    review = make_comment("Trump's onto it!", user, movie)

    repo.add_review(review)

    assert review in repo.get_reviews()