Skip to content

Commit 0ac5c50

Browse files
author
lubos.zlatohlavek
committed
triv: #23799 added test for session retry
1 parent a3e1a81 commit 0ac5c50

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ dev = [
3434
"ruff>=0.11.5",
3535
"openapi-python-client",
3636
"types-requests",
37-
"urllib3 >=2.0"
37+
"urllib3 >=2.0",
38+
"responses"
3839
]
3940

4041
[project.urls]
@@ -135,5 +136,6 @@ DEP002 = [
135136
"pytest-cov",
136137
"ruff",
137138
"openapi-python-client",
138-
"types-requests"
139+
"types-requests",
140+
"responses"
139141
]

tests/test_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import MagicMock, patch
33

44
import pytest
5+
import responses
56

67
from tatrapayplus.client import TatrapayPlusClient
78
from tatrapayplus.enums import SimpleStatus
@@ -317,3 +318,18 @@ def test_saved_card_and_simple_status_data_mocked(mock_request, tatrapay_client)
317318
assert response["simple_status"] == SimpleStatus.AUTHORIZED
318319
assert response["saved_card"]["credit_card"] == "Visa"
319320
assert response["saved_card"]["cid"] == "123"
321+
322+
323+
@responses.activate
324+
def test_retry_policy(tatrapay_client):
325+
url = "https://example.com/test"
326+
retry_count = 3
327+
328+
for _ in range(retry_count):
329+
responses.add(responses.GET, url, status=500)
330+
responses.add(responses.GET, url, status=200, json={"success": True})
331+
332+
response = tatrapay_client.session.get(url)
333+
334+
assert response.status_code == 200
335+
assert len(responses.calls) == retry_count + 1

uv.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)