Добавлено сохранение заказов в postgres

This commit is contained in:
Раис Юсупалиев
2026-04-18 00:33:45 +03:00
parent 2b201a08be
commit bddac60965
38 changed files with 971 additions and 17 deletions
@@ -302,6 +302,9 @@ tbank_payment:
terminal_key: "test-terminal-key"
password: "test-password"
postgres:
dsn: "postgresql+asyncpg://postgres:postgres@localhost:5432/cdek_adapter_test"
observability:
enabled: false
service_name: "cdek-adapter-test-service"
+32 -4
View File
@@ -111,28 +111,56 @@ def test_create_payment_link_posts_signed_payload_and_maps_payment_url() -> None
def test_create_payment_link_maps_4xx_to_request_error() -> None:
response = httpx.Response(
400,
json={"Success": False, "Message": "bad request"},
json={
"Success": False,
"ErrorCode": "101",
"Message": "bad request",
"Details": "invalid token",
},
request=httpx.Request("POST", "https://securepay.tinkoff.ru/v2/Init"),
)
http_client = SequenceHTTPClient([response])
adapter = _make_adapter(http_client)
with pytest.raises(TBankPaymentRequestError, match="status 400"):
with pytest.raises(TBankPaymentRequestError) as exc_info:
asyncio.run(adapter.create_payment_link("order-uuid-1", 125000))
assert exc_info.value.status_code == 400
assert exc_info.value.error_code == "101"
assert exc_info.value.provider_message == "bad request"
assert exc_info.value.details == "invalid token"
assert str(exc_info.value) == (
"TBank payment init request was rejected. "
"status_code=400 error_code=101 message=bad request details=invalid token"
)
def test_create_payment_link_maps_unsuccessful_payload_to_request_error() -> None:
response = httpx.Response(
200,
json={"Success": False, "Message": "bad request"},
json={
"Success": False,
"ErrorCode": "102",
"Message": "duplicate order id",
"Details": "OrderId must be unique",
},
request=httpx.Request("POST", "https://securepay.tinkoff.ru/v2/Init"),
)
http_client = SequenceHTTPClient([response])
adapter = _make_adapter(http_client)
with pytest.raises(TBankPaymentRequestError):
with pytest.raises(TBankPaymentRequestError) as exc_info:
asyncio.run(adapter.create_payment_link("order-uuid-1", 125000))
assert exc_info.value.status_code is None
assert exc_info.value.error_code == "102"
assert exc_info.value.provider_message == "duplicate order id"
assert exc_info.value.details == "OrderId must be unique"
assert str(exc_info.value) == (
"TBank payment init request was rejected. "
"error_code=102 message=duplicate order id details=OrderId must be unique"
)
def test_create_payment_link_maps_transport_errors_to_client_error() -> None:
request = httpx.Request("POST", "https://securepay.tinkoff.ru/v2/Init")