From 4fed42841fc069115285a9db2b93b86379a15bd3 Mon Sep 17 00:00:00 2001 From: Isaac Doidge Date: Wed, 4 Nov 2026 11:14:42 +1000 Subject: [PATCH] test: expect ApiNotFoundError from account_history on a node without the route A node before v12 has no `/history` route and answers HTTP 404 with an empty body. `account_history` raises `ApiNotFoundError`, a subclass of `ApiError`, with `status_code` 404 and the HTTP reason phrase `Not Found` as `message`, which is what `ApiError.message` holds for an empty body. The test and the `account_history` docstring now state that. Co-Authored-By: Claude Sonnet 5.5 --- supra_sdk/clients/rest/account.py | 4 ++-- tests/unit/test_paging.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/supra_sdk/clients/rest/account.py b/supra_sdk/clients/rest/account.py index 4eeb6ee..67aabd7 100644 --- a/supra_sdk/clients/rest/account.py +++ b/supra_sdk/clients/rest/account.py @@ -535,8 +535,8 @@ async def account_history( `account_coin_transactions` does not. Needs a node from `supra_node_v12.0.0`. A node before v12 (Testnet and Mainnet until they run v12) answers - HTTP 404 with an empty body, raised as `supra_sdk.clients.api_client.ApiError` with `status_code` 404 and an - empty `message`. + HTTP 404 with an empty body, raised as `supra_sdk.clients.api_client.ApiNotFoundError` (a subclass of + `ApiError`) with `status_code` 404 and the message `Not Found`, the HTTP reason phrase. Automated transactions and automation registry records are not listed; use `account_automated_transactions` for those. While the node sends the `x-supra-history-indexed-from` response diff --git a/tests/unit/test_paging.py b/tests/unit/test_paging.py index 3651a63..8e10750 100644 --- a/tests/unit/test_paging.py +++ b/tests/unit/test_paging.py @@ -8,8 +8,7 @@ import httpx from supra_sdk.account_address import AccountAddress -from supra_sdk.clients import ApiClient -from supra_sdk.clients.api_client import ApiError +from supra_sdk.clients import ApiClient, ApiNotFoundError from supra_sdk.clients.rest.paging import next_cursor from supra_sdk.clients.rest.rest_types import ( AccountHistoryCategory, @@ -680,12 +679,12 @@ async def test_only_a_missing_header_ends_a_page(self): self.response = page([], "") self.assertEqual(await client.account_history(ADDRESS), ([], None)) - async def test_a_node_without_the_route_raises_api_error(self): + async def test_a_node_without_the_route_raises_not_found_error(self): self.node = await FakeNode.create(lambda _: httpx.Response(404)) - with self.assertRaises(ApiError) as raised: + with self.assertRaises(ApiNotFoundError) as raised: await self.node.client.account_history(ADDRESS) self.assertEqual(raised.exception.status_code, 404) - self.assertEqual(raised.exception.message, "") + self.assertEqual(raised.exception.message, "Not Found") async def test_iterator_pages_past_an_empty_page_and_the_zero_cursor(self): # The node filters by category while it scans: a page can be empty and carry a cursor, and "0" is the