Skip to content

Commit 9d7cfb0

Browse files
authored
Merge branch 'master' into fix_list_functions_too_many
2 parents 1ca469b + 266c7c3 commit 9d7cfb0

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

services/api-server/tests/unit/pact_broker/test_pact_licensed_items.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
from pytest_mock import MockerFixture
1616
from pytest_simcore.helpers.typing_mock import HandlerMockFactory
1717
from simcore_service_api_server._meta import API_VERSION
18-
from simcore_service_api_server.api.dependencies.webserver_rpc import (
19-
get_wb_api_rpc_client,
20-
)
21-
from simcore_service_api_server.services_rpc.wb_api_server import WbApiRpcClient
2218

2319
# Fake response based on values from 05_licensed_items.json
2420
EXPECTED_LICENSED_ITEMS = [
@@ -141,15 +137,9 @@ class DummyRpcClient:
141137
async def mock_wb_api_server_rpc(
142138
app: FastAPI,
143139
mocker: MockerFixture,
140+
mocked_app_rpc_dependencies: None,
144141
mock_handler_in_licenses_rpc_interface: HandlerMockFactory,
145142
) -> None:
146-
from servicelib.rabbitmq.rpc_interfaces.webserver.v1 import ( # noqa: PLC0415
147-
WebServerRpcClient,
148-
)
149-
150-
app.dependency_overrides[get_wb_api_rpc_client] = lambda: WbApiRpcClient(
151-
_rpc_client=mocker.MagicMock(spec=WebServerRpcClient),
152-
)
153143

154144
mock_handler_in_licenses_rpc_interface(
155145
"get_licensed_items", return_value=EXPECTED_LICENSED_ITEMS_PAGE

services/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ services:
716716
# WEBSERVER_SERVER_HOST
717717
WEBSERVER_HOST: ${WEBSERVER_HOST}
718718
WEBSERVER_PORT: ${WEBSERVER_PORT}
719-
WEBSERVER_RPC_NAMESPACE: ${WEBSERVER_HOST}
719+
WEBSERVER_RPC_NAMESPACE: webserver
720720

721721
# WEBSERVER / -> index.html
722722
WEBSERVER_FRONTEND: ${WEBSERVER_FRONTEND}
@@ -953,7 +953,7 @@ services:
953953

954954
WEBSERVER_HOST: ${WEBSERVER_HOST}
955955
WEBSERVER_PORT: ${WEBSERVER_PORT}
956-
WEBSERVER_RPC_NAMESPACE: ${WEBSERVER_HOST}
956+
WEBSERVER_RPC_NAMESPACE: webserver
957957

958958
DIRECTOR_V2_HOST: ${DIRECTOR_V2_HOST}
959959
DIRECTOR_V2_PORT: ${DIRECTOR_V2_PORT}
@@ -1104,7 +1104,7 @@ services:
11041104
WEBSERVER_PRODUCTS: ${WB_GC_PRODUCTS}
11051105
WEBSERVER_PROJECTS: ${WB_GC_PROJECTS}
11061106
WEBSERVER_PUBLICATIONS: ${WB_GC_PUBLICATIONS}
1107-
WEBSERVER_RPC_NAMESPACE: ${WEBSERVER_HOST}
1107+
WEBSERVER_RPC_NAMESPACE: webserver
11081108
WEBSERVER_SCICRUNCH: ${WB_GC_SCICRUNCH}
11091109
WEBSERVER_SOCKETIO: ${WB_GC_SOCKETIO}
11101110
WEBSERVER_STATICWEB: ${WB_GC_STATICWEB}

services/web/server/tests/unit/isolated/test_application_settings.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
# pylint:disable=no-name-in-module
44

55
import json
6+
import logging
67
from typing import Annotated
78

89
import pytest
910
from aiohttp import web
1011
from common_library.json_serialization import json_dumps
12+
from models_library.rpc.webserver import DEFAULT_WEBSERVER_RPC_NAMESPACE
1113
from pydantic import Field, HttpUrl, TypeAdapter
1214
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
1315
from pytest_simcore.helpers.typing_env import EnvVarsDict
@@ -18,6 +20,8 @@
1820
setup_settings,
1921
)
2022

23+
_logger = logging.getLogger(__name__)
24+
2125

2226
@pytest.fixture
2327
def app_settings(
@@ -230,3 +234,50 @@ def test_valid_application_settings(mock_webserver_service_environment: EnvVarsD
230234
assert settings
231235

232236
assert settings == ApplicationSettings.create_from_envs()
237+
238+
239+
@pytest.fixture
240+
def mock_service_environment(
241+
docker_compose_service_environment_dict,
242+
service_name: str,
243+
monkeypatch: pytest.MonkeyPatch,
244+
) -> EnvVarsDict:
245+
# NOTE: the name of the service in real deploys are not necessarily the ones we have here in the docker-compose
246+
# Typically they include prefixes with the deployment name e.g. master-webserver or staging-webserver instead of just webserver
247+
_logger.info("Mocking envs for service: %s", service_name)
248+
249+
assert docker_compose_service_environment_dict
250+
return setenvs_from_dict(monkeypatch, {**docker_compose_service_environment_dict})
251+
252+
253+
@pytest.mark.parametrize(
254+
"service_name", ["webserver", "wb-db-event-listener", "wb-garbage-collector"]
255+
)
256+
def test_webserver_rpc_namespace_must_be_default(mock_service_environment: EnvVarsDict):
257+
# NOTE: This requirement will change when https://github.com/ITISFoundation/osparc-simcore/issues/8448 is implemented
258+
settings = ApplicationSettings.create_from_envs()
259+
assert settings
260+
261+
assert settings.WEBSERVER_RPC_NAMESPACE == DEFAULT_WEBSERVER_RPC_NAMESPACE
262+
263+
264+
@pytest.mark.parametrize("service_name", ["wb-api-server"])
265+
def test_webserver_rpc_namespace_must_be_non_default(
266+
mock_service_environment: EnvVarsDict,
267+
env_devel_dict: EnvVarsDict,
268+
):
269+
settings = ApplicationSettings.create_from_envs()
270+
assert settings
271+
272+
assert settings.WEBSERVER_RPC_NAMESPACE != DEFAULT_WEBSERVER_RPC_NAMESPACE
273+
assert env_devel_dict["WB_API_WEBSERVER_HOST"] == settings.WEBSERVER_RPC_NAMESPACE
274+
275+
276+
@pytest.mark.parametrize("service_name", ["wb-auth"])
277+
def test_webserver_rpc_namespace_must_be_disabled(
278+
mock_service_environment: EnvVarsDict,
279+
):
280+
settings = ApplicationSettings.create_from_envs()
281+
assert settings
282+
283+
assert settings.WEBSERVER_RPC_NAMESPACE is None

0 commit comments

Comments
 (0)