def test_raise_invalid_user_id_exception(self):
        #arrange
        presenter = UserPresenterImplementation()

        #act
        with pytest.raises(NotFound):
            presenter.raise_invalid_user_id_exception()
    def test_raise_invalid_password_exception(self):

        #arrange
        presenter = UserPresenterImplementation()
        #act
        with pytest.raises(Unauthorized):
            presenter.raise_invalid_password_exception()
    def test_is_admin_response(self, is_admin):

        #arrange
        presenter = UserPresenterImplementation()
        expected_response = {"is_admin": is_admin}

        #act
        response = presenter.is_admin_response(is_admin)

        #assert
        assert response == expected_response
    def test_user_logout_response(self):

        #arrange
        presenter = UserPresenterImplementation()
        expected_response = {"status": "Logged out Succesfully"}

        #act
        response = presenter.logout_response()

        #assert
        assert response == expected_response
    def test_get_login_response(self, OAuthTokenDto):

        #arrange
        from .raw_inputs import user_dto
        from .expected_responses import login_response
        oauth_token_dto = OAuthTokenDto
        presenter = UserPresenterImplementation()

        #act
        response = presenter.get_login_response(
            user_dto, oauth_token_dto=oauth_token_dto)

        #assert
        print(response)
        print(login_response)
        assert response == login_response
def api_wrapper(*args, **kwargs):
    # ---------MOCK IMPLEMENTATION---------
    storage = UserStorageImplementation()
    presenter = UserPresenterImplementation()
    interactor = UserLogoutInteractor(storage=storage)

    access_token = kwargs['access_token']
    login_response = interactor.logout_wrapper(access_token=access_token,
                                               presenter=presenter)

    response_data = json.dumps(login_response)
    return HttpResponse(response_data, status=200)
def api_wrapper(*args, **kwargs):

    request_data = kwargs['request_data']
    storage = UserStorageImplementation()
    presenter = UserPresenterImplementation()
    oauth_storage = OAuth2SQLStorage()
    interactor = UserLoginInteractor(storage=storage,
                                     oauth_storage=oauth_storage)

    username = request_data['username']
    password = request_data['password']

    login_response = interactor.login_wrapper(username=username,
                                              password=password,
                                              presenter=presenter)
    response_data = json.dumps(login_response)
    return HttpResponse(response_data, status=200)