Skip to content

Commit

Permalink
should finally work
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Apr 18, 2023
1 parent 7107d65 commit 95383fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,20 @@
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name

import pytest
from aiohttp.test_utils import TestClient
from pytest_simcore.helpers.typing_env import EnvVarsDict
from servicelib.aiohttp.application_keys import APP_SETTINGS_KEY
from simcore_service_webserver.application_settings import ApplicationSettings


def test_module_setup_not_skipped_when_no_dev_features_enabled(client: TestClient):
def test_module_setup_defaults_to_false(client: TestClient):
assert client.app
settings: ApplicationSettings = client.app[APP_SETTINGS_KEY]

assert settings.WEBSERVER_CLUSTERS
assert "list_clusters_handler" in client.app.router


def test_module_setup_applied_when_dev_features_enabled(
enable_dev_features: None, client: TestClient
):
assert client.app
settings: ApplicationSettings = client.app[APP_SETTINGS_KEY]

assert settings.WEBSERVER_CLUSTERS
assert "list_clusters_handler" in client.app.router


@pytest.fixture
def disable_webserver_cluster(
app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("WEBSERVER_CLUSTERS", "false")


def test_module_setup_can_be_properly_disabled(
enable_dev_features: None, disable_webserver_cluster: None, client: TestClient
):
assert client.app
settings: ApplicationSettings = client.app[APP_SETTINGS_KEY]

assert not settings.WEBSERVER_CLUSTERS
assert "list_clusters_handler" not in client.app.router


def test_module_setup_can_be_properly_enabled(
enable_dev_features: None,
enable_webserver_clusters_feature: None,
client: TestClient,
):
Expand Down
5 changes: 3 additions & 2 deletions services/web/server/tests/unit/with_dbs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ def app_environment(app_environment: dict[str, str], monkeypatch: MonkeyPatch) -
print("+ web_server:")
cfg = deepcopy(app_cfg)
env = monkeypatch_setenv_from_app_config(cfg)
monkeypatch.setenv("WEBSERVER_CLUSTERS", "0") # currently defaults to being false
return env | {"WEBSERVER_CLUSTERS": "0"}
return env
# monkeypatch.setenv("WEBSERVER_CLUSTERS", "0") # currently defaults to being false
# return env | {"WEBSERVER_CLUSTERS": "0"}


@pytest.fixture
Expand Down

0 comments on commit 95383fd

Please sign in to comment.