Skip to content

Commit c6b7aff

Browse files
authored
🎨 itis vip syncer: adds periodicity in config ⚠️🚨 (#7221)
1 parent e35a13f commit c6b7aff

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

.env-devel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ FUNCTION_SERVICES_AUTHORS='{"UN": {"name": "Unknown", "email": "[email protected]
141141

142142
WEBSERVER_LICENSES={}
143143
LICENSES_ITIS_VIP_SYNCER_ENABLED=false
144+
LICENSES_ITIS_VIP_SYNCER_PERIODICITY=1D00:00:00
144145
LICENSES_ITIS_VIP_API_URL=https://replace-with-itis-api/{category}
145146
LICENSES_ITIS_VIP_CATEGORIES='{"HumanWholeBody": "Humans", "HumanBodyRegion": "Humans (Region)", "AnimalWholeBody": "Animal"}'
146147
LICENSES_SPEAG_PHANTOMS_API_URL=https://replace-with-speag-api/{category}

services/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ services:
727727

728728
WEBSERVER_LICENSES: ${WEBSERVER_LICENSES}
729729
LICENSES_ITIS_VIP_SYNCER_ENABLED : ${LICENSES_ITIS_VIP_SYNCER_ENABLED}
730+
LICENSES_ITIS_VIP_SYNCER_PERIODICITY: ${LICENSES_ITIS_VIP_SYNCER_PERIODICITY}
730731
LICENSES_ITIS_VIP_API_URL: ${LICENSES_ITIS_VIP_API_URL}
731732
LICENSES_ITIS_VIP_CATEGORIES: ${LICENSES_ITIS_VIP_CATEGORIES}
732733
LICENSES_SPEAG_PHANTOMS_API_URL: ${LICENSES_SPEAG_PHANTOMS_API_URL}

services/web/server/src/simcore_service_webserver/licenses/_itis_vip_syncer_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async def _lifespan(app_: web.Application):
104104
@exclusive_periodic(
105105
get_redis_lock_manager_client_sdk(app_),
106106
task_interval=resync_after,
107-
retry_after=timedelta(minutes=2),
107+
retry_after=timedelta(minutes=1),
108108
)
109109
async def _periodic_sync() -> None:
110110
await sync_licensed_resources(app_, categories=categories)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# pylint: disable=protected-access
2+
# pylint: disable=redefined-outer-name
3+
# pylint: disable=too-many-arguments
4+
# pylint: disable=unused-argument
5+
# pylint: disable=unused-variable
6+
7+
8+
import datetime
9+
10+
import pytest
11+
from pytest_simcore.helpers.typing_env import EnvVarsDict
12+
from simcore_service_webserver.licenses.settings import LicensesSettings
13+
14+
15+
def test_itis_vip_syncer_settings(
16+
mock_webserver_service_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
17+
):
18+
19+
assert "LICENSES_ITIS_VIP_SYNCER_ENABLED" in mock_webserver_service_environment
20+
assert "LICENSES_ITIS_VIP_SYNCER_PERIODICITY" in mock_webserver_service_environment
21+
22+
settings = LicensesSettings.create_from_envs()
23+
assert settings
24+
25+
with monkeypatch.context() as patch:
26+
patch.setenv("LICENSES_ITIS_VIP_SYNCER_PERIODICITY", "1D02:03:04")
27+
28+
settings: LicensesSettings = LicensesSettings.create_from_envs()
29+
assert settings
30+
assert settings.LICENSES_ITIS_VIP_SYNCER_PERIODICITY == datetime.timedelta(
31+
days=1, hours=2, minutes=3, seconds=4
32+
)

0 commit comments

Comments
 (0)