|
1 | | -# pylint:disable=unused-variable |
2 | | -# pylint:disable=unused-argument |
3 | | -# pylint:disable=redefined-outer-name |
| 1 | +# pylint: disable=redefined-outer-name |
| 2 | +# pylint: disable=unused-argument |
| 3 | +# pylint: disable=unused-variable |
| 4 | +# pylint: disable=too-many-arguments |
4 | 5 |
|
5 | 6 | import re |
6 | | -from copy import deepcopy |
7 | 7 |
|
8 | 8 | import pytest |
9 | 9 | from aiohttp import web_exceptions |
10 | 10 | from aioresponses.core import aioresponses |
11 | | -from simcore_service_webserver.application_settings_utils import AppConfigDict |
| 11 | +from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict |
| 12 | +from pytest_simcore.helpers.typing_env import EnvVarsDict |
12 | 13 |
|
13 | 14 |
|
14 | 15 | @pytest.fixture |
15 | | -def app_cfg(default_app_cfg: AppConfigDict, unused_tcp_port_factory): |
16 | | - """App's configuration used for every test in this module |
17 | | -
|
18 | | - NOTE: Overrides services/web/server/tests/unit/with_dbs/conftest.py::app_cfg to influence app setup |
19 | | - """ |
20 | | - cfg = deepcopy(default_app_cfg) |
21 | | - |
22 | | - cfg["main"]["port"] = unused_tcp_port_factory() |
23 | | - cfg["main"]["studies_access_enabled"] = True |
24 | | - |
25 | | - exclude = { |
26 | | - "tracing", |
27 | | - "smtp", |
28 | | - "storage", |
29 | | - "activity", |
30 | | - "diagnostics", |
31 | | - "tags", |
32 | | - "publications", |
33 | | - "catalog", |
34 | | - "computation", |
35 | | - "products", |
36 | | - "socketio", |
37 | | - "resource_manager", |
38 | | - "projects", |
39 | | - "login", |
40 | | - "users", |
41 | | - } |
42 | | - include = { |
43 | | - "db", |
44 | | - "rest", |
45 | | - "groups", |
46 | | - } |
47 | | - |
48 | | - assert include.intersection(exclude) == set() |
49 | | - |
50 | | - for section in include: |
51 | | - cfg[section]["enabled"] = True |
52 | | - for section in exclude: |
53 | | - cfg[section]["enabled"] = False |
54 | | - |
55 | | - # NOTE: To see logs, use pytest -s --log-cli-level=DEBUG |
56 | | - ## setup_logging(level=logging.DEBUG) |
57 | | - |
58 | | - return cfg |
| 16 | +def app_environment( |
| 17 | + monkeypatch: pytest.MonkeyPatch, |
| 18 | + app_environment: EnvVarsDict, |
| 19 | +) -> EnvVarsDict: |
| 20 | + |
| 21 | + monkeypatch.delenv("WEBSERVER_STUDIES_DISPATCHER", raising=False) |
| 22 | + app_environment.pop("WEBSERVER_STUDIES_DISPATCHER", None) |
| 23 | + |
| 24 | + return app_environment | setenvs_from_dict( |
| 25 | + monkeypatch, |
| 26 | + { |
| 27 | + # exclude |
| 28 | + "WEBSERVER_ACTIVITY": "null", |
| 29 | + "WEBSERVER_CATALOG": "null", |
| 30 | + "WEBSERVER_CLUSTERS": "null", |
| 31 | + "WEBSERVER_COMPUTATION": "null", |
| 32 | + "WEBSERVER_DIAGNOSTICS": "null", |
| 33 | + "WEBSERVER_EMAIL": "null", |
| 34 | + "WEBSERVER_GARBAGE_COLLECTOR": "null", |
| 35 | + "WEBSERVER_GROUPS": "0", |
| 36 | + "WEBSERVER_LOGIN": "null", |
| 37 | + "WEBSERVER_PRODUCTS": "0", |
| 38 | + "WEBSERVER_PROJECTS": "null", |
| 39 | + "WEBSERVER_PUBLICATIONS": "0", |
| 40 | + "WEBSERVER_SOCKETIO": "0", |
| 41 | + "WEBSERVER_STORAGE": "null", |
| 42 | + "WEBSERVER_RESOURCE_MANAGER": "null", |
| 43 | + "WEBSERVER_TAGS": "0", |
| 44 | + "WEBSERVER_TRACING": "null", |
| 45 | + "WEBSERVER_USERS": "null", |
| 46 | + }, |
| 47 | + ) |
59 | 48 |
|
60 | 49 |
|
61 | 50 | @pytest.mark.skip(reason="UNDER DEV: test_group_handlers") |
|
0 commit comments