Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions services/web/server/tests/unit/with_dbs/01/test_api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments

import asyncio
from collections.abc import AsyncIterable
from datetime import timedelta
from http import HTTPStatus
Expand All @@ -29,7 +28,12 @@
)
from simcore_service_webserver.application_settings import GarbageCollectorSettings
from simcore_service_webserver.db.models import UserRole
from tenacity import retry_if_exception_type, stop_after_attempt, wait_fixed
from tenacity import (
retry_if_exception_type,
stop_after_attempt,
stop_after_delay,
wait_fixed,
)


@pytest.fixture
Expand Down Expand Up @@ -172,9 +176,15 @@ async def test_create_api_key_with_expiration(
assert [d["displayName"] for d in data] == ["foo"]

# wait for api-key for it to expire and force-run scheduled task
await asyncio.sleep(expiration_interval.seconds)
deleted = await prune_expired_api_keys(client.app)
assert deleted == ["foo"]
async for attempt in tenacity.AsyncRetrying(
wait=wait_fixed(1),
retry=retry_if_exception_type(AssertionError),
stop=stop_after_delay(5 * expiration_interval.seconds),
reraise=True,
):
with attempt:
deleted = await prune_expired_api_keys(client.app)
assert deleted == ["foo"]

resp = await client.get("/v0/auth/api-keys")
data, _ = await assert_status(resp, expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments

from datetime import timedelta
from datetime import datetime, timedelta
from uuid import UUID

import arrow
Expand Down Expand Up @@ -55,7 +55,9 @@ async def test_patch_project(
assert client.app

# This will change after in patched_project
assert user_project["creationDate"] == user_project["lastChangeDate"]
creation_date = datetime.fromisoformat(user_project["creationDate"])
last_change_date = datetime.fromisoformat(user_project["lastChangeDate"])
assert abs(creation_date - last_change_date) < timedelta(seconds=1)

# Patch valid project
patch_data = {"name": "Updated Project Name"}
Expand Down
Loading