Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SeamApiException to SeamHttpApiError #58

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion seam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions seam/request.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions seam/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from seam.routes.types import AbstractRoutes, Workspace


class SeamApiException(Exception):
class SeamHttpApiError(Exception):
def __init__(
self,
response,
Expand All @@ -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}"
)


Expand Down
4 changes: 2 additions & 2 deletions test/access_codes/test_access_codes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from seam import Seam
from seam.types import SeamApiException
from seam.types import SeamHttpApiError
import pytest


Expand Down Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions test/connected_accounts/test_connected_accounts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from seam import Seam
from seam.types import SeamApiException
from seam.types import SeamHttpApiError

EMAIL = "[email protected]"

Expand Down Expand Up @@ -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"
4 changes: 2 additions & 2 deletions test/devices/test_devices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from seam import Seam
from seam.types import SeamApiException
from seam.types import SeamHttpApiError


def test_devices(seam: Seam):
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/events/test_events.py
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from seam import Seam
from seam.types import SeamApiException
from seam.types import SeamHttpApiError
import pytest


Expand Down