Skip to content

Commit 9d537d6

Browse files
committed
fix: QA linting issues
1 parent c5b610f commit 9d537d6

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
from http import HTTPStatus
22
import json
3-
43
from ..abstract_base_client import AbstractBaseClient
54
from ..errors.server_error import ServerError
65

6+
# Define constants for response values
7+
OK_RESPONSE = "OK"
8+
STATUS_OK = "ok"
9+
710
async def ping(client: AbstractBaseClient) -> None:
811
response = await client.http_client.get('/api/v1/ping')
912
response_body = bytes.decode(await response.body.read(), encoding='utf-8')
1013

14+
if response.status_code != HTTPStatus.OK:
15+
raise ServerError(f'Received unexpected response: {response_body}')
16+
17+
# Check old format (plain "OK")
18+
if response_body == OK_RESPONSE:
19+
return
20+
21+
# Check new format (JSON {"status":"ok"})
1122
try:
1223
response_json = json.loads(response_body)
24+
if isinstance(response_json, dict) and response_json.get('status') == STATUS_OK:
25+
return
1326
except json.JSONDecodeError:
1427
pass
15-
else:
16-
if isinstance(response_json, dict) and response_json.get('status') == 'ok':
17-
return None
18-
raise ServerError(f'Received unexpected response: {response_body}')
28+
29+
raise ServerError(f'Received unexpected response: {response_body}')

tests/shared/start_local_http_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def ping_app() -> RetryResult[None]:
4848
async with session:
4949
try:
5050
response = await session.get(
51-
f'http://localhost:{local_http_server.port}/__python_test__/api/v1/ping', timeout=1
51+
f'http://localhost:{local_http_server.port}/__python_test__/api/v1/ping', timeout=aiohttp.ClientTimeout(total=1)
5252
)
5353
except aiohttp.ClientError as error:
5454
return Retry(cause=error)

0 commit comments

Comments
 (0)