Skip to content

Commit 20816a9

Browse files
committed
use tenacity @pcrespov @GitHK
1 parent 6407917 commit 20816a9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

services/web/server/tests/unit/with_dbs/01/test_api_keys.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from http.client import HTTPException
1111

1212
import pytest
13+
import tenacity
1314
from aiohttp.test_utils import TestClient
1415
from faker import Faker
1516
from models_library.products import ProductName
@@ -28,6 +29,7 @@
2829
)
2930
from simcore_service_webserver.application_settings import GarbageCollectorSettings
3031
from simcore_service_webserver.db.models import UserRole
32+
from tenacity import retry_if_exception_type, stop_after_attempt, wait_fixed
3133

3234

3335
@pytest.fixture
@@ -245,5 +247,10 @@ async def test_prune_expired_api_keys_task_is_triggered(
245247
APP_SETTINGS_KEY
246248
].WEBSERVER_GARBAGE_COLLECTOR
247249
assert isinstance(settings, GarbageCollectorSettings)
248-
await asyncio.sleep(2 * settings.GARBAGE_COLLECTOR_PRUNE_APIKEYS_INTERVAL_S)
249-
mock.assert_called()
250+
async for attempt in tenacity.AsyncRetrying(
251+
stop=stop_after_attempt(5),
252+
wait=wait_fixed(1),
253+
retry=retry_if_exception_type(AssertionError),
254+
):
255+
with attempt:
256+
mock.assert_called()

0 commit comments

Comments
 (0)