|
3 | 3 | import httpx |
4 | 4 | import pytest |
5 | 5 |
|
6 | | -from epoint import EpointClient, GatewayError |
| 6 | +from epoint import CardStatus, EpointClient, GatewayError, Status |
7 | 7 |
|
8 | 8 | pytestmark = pytest.mark.sandbox |
9 | 9 |
|
@@ -144,3 +144,28 @@ def test_missing_required_field_is_refused(client): |
144 | 144 | with pytest.raises(GatewayError) as info: |
145 | 145 | client._post("/api/1/request", {"amount": "10.00", "currency": "AZN"}) |
146 | 146 | assert "order_id" in str(info.value) |
| 147 | + |
| 148 | + |
| 149 | +def test_the_statuses_the_sandbox_returns_are_all_in_the_enum(client, pay): |
| 150 | + """Guards against the enum drifting away from what the API actually sends.""" |
| 151 | + paid = client.create_payment(amount=5, order_id=order()) |
| 152 | + pay(client, paid.redirect_url) |
| 153 | + |
| 154 | + declined = client.create_payment(amount=5, order_id=order()) |
| 155 | + pay(client, declined.redirect_url, card="4000000000000116") |
| 156 | + |
| 157 | + seen = { |
| 158 | + client.get_status(paid.transaction).status, |
| 159 | + client.get_status(declined.transaction).status, |
| 160 | + } |
| 161 | + assert seen == {Status.SUCCESS, Status.FAILED} |
| 162 | + assert all(s in set(Status) for s in seen) |
| 163 | + |
| 164 | + |
| 165 | +def test_a_card_status_from_the_sandbox_is_in_the_enum(client, pay): |
| 166 | + registered = client.register_card(description="enum check") |
| 167 | + pay(client, registered.redirect_url) |
| 168 | + |
| 169 | + card = client.get_card_status(registered["card_id"]) |
| 170 | + assert card.get("status") == CardStatus.ACTIVE |
| 171 | + assert card.get("status") in set(CardStatus) |
0 commit comments