def api_delete_comment(): """ Delete a comment. Requires a valid JWT """ claims = get_jwt_claims() user_email = User.from_claims(claims).email post_data = request.get_json() try: comment_id = expect(post_data.get('comment_id'), str, 'comment_id') movie_id = expect(post_data.get('movie_id'), str, 'movie_id') delete_comment(comment_id, user_email) updated_comments = get_movie(movie_id).get('comments') return jsonify({'comments': updated_comments}), 200 except Exception as e: return jsonify({'error': str(e)}), 400
def test_delete_is_given(client): # we are mainly running this for cleanup to delete the comment result = delete_comment(comment['id'], test_user['email']) assert result.raw_result.get('n') == 1
def test_delete_comment_should_delete_if_email_is_owner(client): result = delete_comment(comment['id'], test_user['email']) assert result.raw_result.get('n') == 1
def test_should_not_delete_comment_if_email_does_not_match(client): result = delete_comment(comment['id'], "*****@*****.**") assert result.raw_result.get('n') == 0
def test_delete_is_given(client): # we are mainly running this for cleanup to delete the comment result = delete_comment(comment["id"], test_user["email"]) assert result.raw_result.get("n") == 1
def test_delete_comment_should_delete_if_email_is_owner(client): result = delete_comment(comment["id"], test_user["email"]) assert result.raw_result.get("n") == 1