From 1b71618d314a38c1501d079e7a0afd7584ebabce Mon Sep 17 00:00:00 2001 From: SporeStack Date: Fri, 14 Apr 2023 23:02:04 +0000 Subject: [PATCH] v10.1.2: Fix exception handling for HTTP 4XX responses --- CHANGELOG.md | 6 +++++- src/sporestack/__init__.py | 2 +- tests/test_api_client.py | 4 +++- tox.ini | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b63e3a..415b550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Nothing yet. + +## [10.1.2] + ## Fixed - HTTP 4XX errors now raise a `SporeStackUserError` instead of `SporeStackServerError`. -## [10.2.0 - 2023-04-14] +## [10.1.1 - 2023-04-14] ## Added diff --git a/src/sporestack/__init__.py b/src/sporestack/__init__.py index cd1b538..a1ecb15 100644 --- a/src/sporestack/__init__.py +++ b/src/sporestack/__init__.py @@ -2,4 +2,4 @@ __all__ = ["api", "api_client", "exceptions"] -__version__ = "10.1.1" +__version__ = "10.1.2" diff --git a/tests/test_api_client.py b/tests/test_api_client.py index 694fc84..4f161ea 100644 --- a/tests/test_api_client.py +++ b/tests/test_api_client.py @@ -3,6 +3,8 @@ import pytest import respx from sporestack import api_client, exceptions +# respx seems to ignore the uri://domain if you don't specify it. + def test__is_onion_url() -> None: onion_url = "http://spore64i5sofqlfz5gq2ju4msgzojjwifls7" @@ -85,7 +87,7 @@ def test_token_info(respx_mock: respx.MockRouter) -> None: "days_remaining": 0, } route_response = httpx.Response(200, json=response_json) - route = respx_mock.get(f"https://api.sporestack.com/token/{dummy_token}/info").mock( + route = respx_mock.get(f"/token/{dummy_token}/info").mock( return_value=route_response ) diff --git a/tox.ini b/tox.ini index 5e10753..9fbca7a 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ deps = pytest-socket~=0.6.0 pytest-cov~=4.0 pytest-mock~=3.6 + respx~=0.20.1 commands = pytest --cov=sporestack --cov-fail-under=39 --cov-report=term --durations=3 sporestack api-endpoint