diff --git a/seam/__init__.py b/seam/__init__.py index a85c80f..e6a9dbe 100644 --- a/seam/__init__.py +++ b/seam/__init__.py @@ -2,7 +2,7 @@ # type: ignore from seam.seam import Seam -from seam.types import SeamApiException +from seam.types import SeamHttpApiError from seam.seam_multi_workspace import SeamMultiWorkspace from seam.options import SeamHttpInvalidOptionsError from seam.auth import SeamHttpInvalidTokenError diff --git a/seam/request.py b/seam/request.py index 11dcc84..df6ac5e 100644 --- a/seam/request.py +++ b/seam/request.py @@ -1,7 +1,7 @@ import requests from importlib.metadata import version -from seam.types import AbstractRequestMixin, SeamApiException +from seam.types import AbstractRequestMixin, SeamHttpApiError class RequestMixin(AbstractRequestMixin): @@ -20,7 +20,7 @@ def make_request(self, method: str, path: str, **kwargs): Raises ------ - SeamApiException: If the response status code is not successful. + SeamHttpApiError: If the response status code is not successful. """ url = self._endpoint + path @@ -39,7 +39,7 @@ def make_request(self, method: str, path: str, **kwargs): response = requests.request(method, url, headers=headers, **kwargs) if response.status_code != 200: - raise SeamApiException(response) + raise SeamHttpApiError(response) if "application/json" in response.headers["content-type"]: return response.json() diff --git a/seam/types.py b/seam/types.py index 5afcd03..6c6be79 100644 --- a/seam/types.py +++ b/seam/types.py @@ -5,7 +5,7 @@ from seam.routes.types import AbstractRoutes, Workspace -class SeamApiException(Exception): +class SeamHttpApiError(Exception): def __init__( self, response, @@ -19,7 +19,7 @@ def __init__( self.metadata = parsed_response.get("error", None) super().__init__( - f"SeamApiException: status={self.status_code}, request_id={self.request_id}, metadata={self.metadata}" + f"SeamHttpApiError: status={self.status_code}, request_id={self.request_id}, metadata={self.metadata}" ) diff --git a/test/access_codes/test_access_codes.py b/test/access_codes/test_access_codes.py index a325a4c..f077e3e 100644 --- a/test/access_codes/test_access_codes.py +++ b/test/access_codes/test_access_codes.py @@ -1,5 +1,5 @@ from seam import Seam -from seam.types import SeamApiException +from seam.types import SeamHttpApiError import pytest @@ -31,7 +31,7 @@ def test_access_codes(seam: Seam): ) assert access_code.code == "4444" - with pytest.raises(SeamApiException): + with pytest.raises(SeamHttpApiError): seam.access_codes.create( device_id=some_device.device_id, name="Duplicate Access Code", code="4444" ) diff --git a/test/connected_accounts/test_connected_accounts.py b/test/connected_accounts/test_connected_accounts.py index d45e5f1..5ee9ccb 100644 --- a/test/connected_accounts/test_connected_accounts.py +++ b/test/connected_accounts/test_connected_accounts.py @@ -1,5 +1,5 @@ from seam import Seam -from seam.types import SeamApiException +from seam.types import SeamHttpApiError EMAIL = "john@example.com" @@ -27,5 +27,5 @@ def test_connected_accounts(seam: Seam): # connected_account and email parameters are not provided. try: seam.connected_accounts.get() - except SeamApiException as e: + except SeamHttpApiError as e: assert e.metadata["message"] == "Invalid input" diff --git a/test/devices/test_devices.py b/test/devices/test_devices.py index 4e15938..83eaf42 100644 --- a/test/devices/test_devices.py +++ b/test/devices/test_devices.py @@ -1,5 +1,5 @@ from seam import Seam -from seam.types import SeamApiException +from seam.types import SeamHttpApiError def test_devices(seam: Seam): @@ -61,7 +61,7 @@ def test_devices(seam: Seam): try: seam.devices.get(name="foo") assert False - except SeamApiException as error: + except SeamHttpApiError as error: assert error.status_code == 404 assert type(error.request_id) == str assert error.metadata["type"] == "device_not_found" diff --git a/test/events/test_events.py b/test/events/test_events.py index 02f1cf7..b860909 100644 --- a/test/events/test_events.py +++ b/test/events/test_events.py @@ -1,7 +1,7 @@ import time from seam import Seam -from seam.types import SeamApiException +from seam.types import SeamHttpApiError SINCE = "2021-01-01T00:00:00.000Z" EVENT_TYPE = "device.connected" @@ -24,5 +24,5 @@ def test_events(seam: Seam): try: seam.events.get(event_id=FAKE_UUID) - except SeamApiException as e: + except SeamHttpApiError as e: assert e.metadata["message"] == "Event not found" diff --git a/test/noise_sensors/noise_thresholds/test_noise_thresholds.py b/test/noise_sensors/noise_thresholds/test_noise_thresholds.py index a869b56..bc8102c 100644 --- a/test/noise_sensors/noise_thresholds/test_noise_thresholds.py +++ b/test/noise_sensors/noise_thresholds/test_noise_thresholds.py @@ -1,6 +1,6 @@ import time from seam import Seam -from seam.types import SeamApiException +from seam.types import SeamHttpApiError import pytest