поправлена гонка статусов от tabnk
Deploy / deploy (push) Successful in 48s

This commit is contained in:
Раис Юсупалиев
2026-06-20 00:57:40 +03:00
parent cbcd9ca1bc
commit aeee641c6c
8 changed files with 173 additions and 16 deletions
@@ -1,5 +1,6 @@
import asyncio
from typing import Any
from unittest.mock import patch
import httpx
import pytest
@@ -87,6 +88,55 @@ def test_get_order_parses_status_and_waybill_uuid() -> None:
assert http_client.calls[0]["headers"] == {"Authorization": "Bearer test-token"}
def test_get_order_logs_request_errors() -> None:
response = httpx.Response(
200,
json={
"entity": {"uuid": "cdek-order-uuid", "statuses": []},
"requests": [
{
"request_uuid": "request-uuid",
"type": "CREATE",
"state": "INVALID",
"errors": [
{
"code": "invalid_order",
"message": "Order data is invalid",
}
],
}
],
},
request=httpx.Request(
"GET", "https://api.cdek.test/v2/orders/cdek-order-uuid"
),
)
client = _make_client(SequenceHTTPClient([response]))
with patch(
"app.adapters.delivery_providers.cdek.client.log.warning"
) as warning_mock:
asyncio.run(client.get_order("cdek-order-uuid"))
warning_mock.assert_called_once_with(
"cdek_order_request_errors",
cdek_order_uuid="cdek-order-uuid",
requests=[
{
"request_uuid": "request-uuid",
"type": "CREATE",
"state": "INVALID",
"errors": [
{
"code": "invalid_order",
"message": "Order data is invalid",
}
],
}
],
)
def test_get_order_retries_on_5xx_and_succeeds() -> None:
flaky = httpx.Response(
503,