Exemple #1
0
    def test_with_malformed_json(self):
        resp = mock.Mock(text='{foo')
        with pytest.raises(InvalidRequestError) as e:
            handle_api_error(resp, 400)

        assert str(e.value) == 'None'
        assert e.value.json_body is None
    def test_with_malformed_json(self):
        resp = mock.Mock(text="{foo")
        with pytest.raises(InvalidRequestError) as e:
            handle_api_error(resp, 400)

        assert str(e.value) == "None"
        assert e.value.json_body is None
    def test_exception_info(self):
        resp = mock.Mock(text='{"message": "foo"}')
        with pytest.raises(InvalidRequestError) as e:
            handle_api_error(resp, 400)

        e = e.value
        assert str(e) == "foo"
        assert e.http_body == '{"message": "foo"}'
        assert e.http_status == 400
        assert e.json_body == {"message": "foo"}
Exemple #4
0
    def test_exception_info(self):
        resp = mock.Mock(text='{"message": "foo"}')
        with pytest.raises(InvalidRequestError) as e:
            handle_api_error(resp, 400)

        e = e.value
        assert str(e) == 'foo'
        assert e.http_body == '{"message": "foo"}'
        assert e.http_status == 400
        assert e.json_body == {'message': 'foo'}
 def test_invalid_request(self):
     resp = mock.Mock(text="")
     with pytest.raises(InvalidRequestError):
         handle_api_error(resp, 404)
     with pytest.raises(InvalidRequestError):
         handle_api_error(resp, 405)
     with pytest.raises(InvalidRequestError):
         handle_api_error(resp, 409)
Exemple #6
0
 def test_invalid_request(self):
     resp = mock.Mock(text='')
     with pytest.raises(InvalidRequestError):
         handle_api_error(resp, 404)
     with pytest.raises(InvalidRequestError):
         handle_api_error(resp, 405)
     with pytest.raises(InvalidRequestError):
         handle_api_error(resp, 409)
 def test_server_error(self):
     resp = mock.Mock(text="")
     with pytest.raises(ServerError):
         handle_api_error(resp, 500)
 def test_authentication_error(self):
     resp = mock.Mock(text="")
     with pytest.raises(AuthenticationError):
         handle_api_error(resp, 401)
Exemple #9
0
 def test_server_error(self):
     resp = mock.Mock(text='')
     with pytest.raises(ServerError):
         handle_api_error(resp, 500)
Exemple #10
0
 def test_authentication_error(self):
     resp = mock.Mock(text='')
     with pytest.raises(AuthenticationError):
         handle_api_error(resp, 401)