Skip to content

Commit af4d430

Browse files
committed
fixes tests
1 parent 6982f42 commit af4d430

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

services/web/server/src/simcore_service_webserver/exporter/plugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
logger=_logger,
1717
)
1818
def setup_exporter(app: web.Application) -> bool:
19+
setup_scicrunch(app)
1920

2021
# Rest-API routes: maps handlers with routes tags with "viewer" based on OAS operation_id
2122
app.router.add_routes(_handlers.routes)
2223

23-
setup_scicrunch(app)
24-
2524
return True

services/web/server/src/simcore_service_webserver/scicrunch/settings.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Annotated
2+
13
from aiohttp import web
24
from pydantic import Field, HttpUrl, SecretStr, TypeAdapter
35
from settings_library.base import BaseCustomSettings
@@ -10,21 +12,17 @@
1012

1113
class SciCrunchSettings(BaseCustomSettings):
1214

13-
SCICRUNCH_API_BASE_URL: HttpUrl = Field(
14-
default=TypeAdapter(HttpUrl).validate_python(f"{SCICRUNCH_DEFAULT_URL}/api/1"),
15-
description="Base url to scicrunch API's entrypoint",
16-
)
15+
SCICRUNCH_API_BASE_URL: Annotated[
16+
HttpUrl, Field(description="Base url to scicrunch API's entrypoint")
17+
] = TypeAdapter(HttpUrl).validate_python(f"{SCICRUNCH_DEFAULT_URL}/api/1")
1718

1819
# NOTE: Login in https://scicrunch.org and get API Key under My Account -> API Keys
1920
# WARNING: this needs to be setup in osparc-ops before deploying
2021
SCICRUNCH_API_KEY: SecretStr
2122

22-
SCICRUNCH_RESOLVER_BASE_URL: HttpUrl = Field(
23-
default=TypeAdapter(HttpUrl).validate_python(
24-
f"{SCICRUNCH_DEFAULT_URL}/resolver"
25-
),
26-
description="Base url to scicrunch resolver entrypoint",
27-
)
23+
SCICRUNCH_RESOLVER_BASE_URL: Annotated[
24+
HttpUrl, Field(description="Base url to scicrunch resolver entrypoint")
25+
] = TypeAdapter(HttpUrl).validate_python(f"{SCICRUNCH_DEFAULT_URL}/resolver")
2826

2927

3028
def get_plugin_settings(app: web.Application) -> SciCrunchSettings:

services/web/server/tests/integration/01/test_exporter_requests_handlers.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pytest
1515
import redis.asyncio as aioredis
1616
from aiohttp.test_utils import TestClient
17+
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
1718
from pytest_simcore.helpers.webserver_login import LoggedUser, UserInfoDict
1819
from pytest_simcore.helpers.webserver_projects import (
1920
create_project,
@@ -152,6 +153,7 @@ async def client(
152153
redis_client: aioredis.Redis,
153154
rabbit_service: RabbitSettings,
154155
simcore_services_ready: None,
156+
monkeypatch: pytest.MonkeyPatch,
155157
) -> Iterable[TestClient]:
156158
# test config & env vars ----------------------
157159
cfg = deepcopy(app_config)
@@ -163,11 +165,20 @@ async def client(
163165

164166
monkeypatch_setenv_from_app_config(cfg)
165167

168+
monkeypatch.delenv("WEBSERVER_SCICRUNCH", raising=False)
169+
setenvs_from_dict(
170+
monkeypatch, {"SCICRUNCH_API_KEY": "REPLACE_ME_with_valid_api_key"}
171+
)
172+
166173
# app setup ----------------------------------
167174
app = create_safe_application(cfg)
168175

169176
# activates only security+restAPI sub-modules
170-
assert setup_settings(app)
177+
app_settings = setup_settings(app)
178+
179+
assert app_settings.WEBSERVER_SCICRUNCH is not None
180+
assert app_settings.WEBSERVER_RABBITMQ is not None
181+
assert app_settings.WEBSERVER_EXPORTER is not None
171182
assert (
172183
exporter_settings.get_plugin_settings(app) is not None
173184
), "Should capture defaults"

0 commit comments

Comments
 (0)