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)
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)
def get_movie_by_rank(repo: AbstractRepository, rank: int): res = repo.get_movie_by_rank(rank) return res