Example #1
0
def api_wrapper(*args, **kwargs):
    # ---------MOCK IMPLEMENTATION---------

    post_id = kwargs['post_id']
    user = kwargs['user']
    try:
        delete_post(
            user_id=user.id,
            post_id=post_id,
        )
    except InvalidPostException:
        raise NotFound(*INVALID_POST_ID)
    except UserCannotDeletePostException:
        raise Forbidden(*UNAUTHORISED_USER_TYPE)
    return HttpResponse(status=200)


    """
def test_delete_post_valid(user2, post2):
    #arrange
    #act
    delete_post(1, 1)
    #assert
    assert list(Post.objects.filter(id=1, posted_by_id=1)) == []
def test_delete_post_user_id_not_creator_of_post(user2, post2):
    #arrange
    #act
    with pytest.raises(UserCannotDeletePostException):
        delete_post(1, 2)
def test_delete_post_post_id_invalid(user, post):
    #arrange
    #act
    with pytest.raises(InvalidPostException):
        delete_post(1, 3)
def test_delete_post_user_id_invalid(user, post):

    #arrange
    #act
    with pytest.raises(InvalidUserException):
        delete_post(3, 1)