diff --git a/tests/api_test.py b/tests/api_test.py index c508b41..2442523 100644 --- a/tests/api_test.py +++ b/tests/api_test.py @@ -77,7 +77,13 @@ def test_api_raises_exception_with_if_data_status_is_false(self, request_mock): ubersmith_api = ubersmith_client.api.init(self.url, self.username, self.password) self.expect_a_ubersmith_call(request_mock, method="client.miss", data=data) - assert_that(calling(ubersmith_api.client.miss), raises(ubersmith_client.exceptions.UbersmithException)) + + with self.assertRaises(ubersmith_client.exceptions.UbersmithException) as cm: + ubersmith_api.client.miss() + + catched_exception = cm.exception + assert_that(catched_exception.code, equal_to(1)) + assert_that(catched_exception.message, equal_to('invalid method specified: client.miss')) @requests_mock.mock() def test_api_raises_exception_for_invalid_status_code(self, request_mock): diff --git a/ubersmith_client/api.py b/ubersmith_client/api.py index 14d41bf..be7c66d 100644 --- a/ubersmith_client/api.py +++ b/ubersmith_client/api.py @@ -69,8 +69,8 @@ def process_request(self, http_method, **kwargs): response_json = response.json() if not response_json['status']: raise UbersmithException( - 500, - "error {0}, {1}".format(response_json['error_code'], response_json['error_message']) + response_json['error_code'], + response_json['error_message'] ) return response.json()["data"]