예제 #1
0
def get_comments_for_movie(movie_rank: int, repo: AbstractRepository):
    movie = repo.get_movie_by_rank(movie_rank)

    if movie is None:
        raise NonExistentMovieException

    return comments_to_dict(movie.comments)
예제 #2
0
def add_comment(movie_rank: int, comment_text: str, username: str, repo: AbstractRepository):
    # Check that the article exists.
    movie = repo.get_movie_by_rank(movie_rank)

    if movie is None:
        raise NonExistentMovieException

    user = repo.get_user(username)
    if user is None:
        raise UnknownUserException

    # Create comment.
    comment = make_comment(comment_text, user, movie)

    # Update the repository.
    repo.add_comment(comment)
예제 #3
0
def get_movie_by_rank(repo: AbstractRepository, rank: int):
    res = repo.get_movie_by_rank(rank)
    return res