Добавлено сохранение заказов в postgres
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user