reduce retries

This commit is contained in:
9qeklajc
2026-04-22 23:14:45 +02:00
parent 4e03145323
commit afd81aeca2
+3 -17
View File
@@ -316,34 +316,21 @@ async def test_concurrent_refund_requests(
assert response.status_code == 200
api_key = response.json()["api_key"]
# Create multiple concurrent refund requests
[
{
"method": "POST",
"url": "/v1/wallet/refund",
"headers": {"Authorization": f"Bearer {api_key}"},
}
for _ in range(5)
]
# Execute concurrently with exception handling
# Execute two concurrent refund requests (sufficient to test concurrency)
async def refund_request(client: AsyncClient, api_key: str) -> Any:
try:
headers = {"Authorization": f"Bearer {api_key}"}
return await client.post("/v1/wallet/refund", headers=headers)
except Exception as e:
# Return a mock response for exceptions
class MockResponse:
status_code = 500
text = str(e)
return MockResponse()
# Create tasks
tasks = [refund_request(integration_client, api_key) for _ in range(5)]
tasks = [refund_request(integration_client, api_key) for _ in range(2)]
responses = await asyncio.gather(*tasks, return_exceptions=False)
# Count successes and failures
successful = [
r for r in responses if hasattr(r, "status_code") and r.status_code == 200
]
@@ -351,9 +338,8 @@ async def test_concurrent_refund_requests(
r for r in responses if hasattr(r, "status_code") and r.status_code != 200
]
# At least one should succeed (the first one)
assert len(successful) >= 1
assert len(successful) + len(failed) == 5
assert len(successful) + len(failed) == 2
@pytest.mark.integration