fix manual parser refresh reliability
All checks were successful
All checks were successful
This commit is contained in:
@@ -49,6 +49,35 @@ class GispProductsClientTest(SimpleTestCase):
|
||||
):
|
||||
GispProductsClient(max_records=10_001)
|
||||
|
||||
def test_retries_transient_server_error(self):
|
||||
calls = 0
|
||||
|
||||
def handle_page(_request, _body: bytes) -> Response:
|
||||
nonlocal calls
|
||||
calls += 1
|
||||
if calls == 1:
|
||||
return Response(status=504, body=b"gateway timeout")
|
||||
return Response(
|
||||
body=b'{"ok":true,"total_count":1,"items":[]}',
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
with HTTPTestServer() as server:
|
||||
server.add_route("POST", "/pp719v2/pub/prod/b/", handle_page)
|
||||
client = GispProductsClient(
|
||||
base_url=server.base_url,
|
||||
max_pages=1,
|
||||
retry_backoff_seconds=0,
|
||||
http_adapter=server.adapter,
|
||||
)
|
||||
with self.assertRaisesMessage(
|
||||
GispProductsClientError,
|
||||
"empty page before total_count",
|
||||
):
|
||||
client.fetch_products()
|
||||
|
||||
self.assertEqual(calls, 2)
|
||||
|
||||
def test_fetch_products_follows_skip_pagination_and_maps_items(self):
|
||||
requests: list[dict] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user