9
9
10
10
import pytest
11
11
from aioresponses import aioresponses
12
+ from pytest_simcore .helpers .monkeypatch_envs import setenvs_from_dict
12
13
from pytest_simcore .helpers .typing_env import EnvVarsDict
13
14
from pytest_simcore .helpers .webserver_login import UserInfoDict
14
15
from pytest_simcore .helpers .webserver_projects import NewProject , delete_all_projects
40
41
@pytest .fixture
41
42
def app_environment (
42
43
monkeypatch : pytest .MonkeyPatch ,
43
- app_cfg : AppConfigDict ,
44
44
app_environment : EnvVarsDict ,
45
- monkeypatch_setenv_from_app_config : Callable [[AppConfigDict ], EnvVarsDict ],
46
45
) -> EnvVarsDict :
47
- cfg = deepcopy (app_cfg )
48
-
49
- cfg ["projects" ]["enabled" ] = True
50
- cfg ["resource_manager" ][
51
- "garbage_collection_interval_seconds"
52
- ] = DEFAULT_GARBAGE_COLLECTOR_INTERVAL_SECONDS # increase speed of garbage collection
53
- cfg ["resource_manager" ][
54
- "resource_deletion_timeout_seconds"
55
- ] = DEFAULT_GARBAGE_COLLECTOR_DELETION_TIMEOUT_SECONDS # reduce deletion delay
46
+ # NOTE: undos some app_environment settings
47
+ monkeypatch .delenv ("WEBSERVER_GARBAGE_COLLECTOR" , raising = False )
48
+ app_environment .pop ("WEBSERVER_GARBAGE_COLLECTOR" , None )
56
49
57
- return app_environment | monkeypatch_setenv_from_app_config (cfg )
50
+ return app_environment | setenvs_from_dict (
51
+ monkeypatch ,
52
+ {
53
+ # reduce deletion delay
54
+ "RESOURCE_MANAGER_RESOURCE_TTL_S" : f"{ DEFAULT_GARBAGE_COLLECTOR_INTERVAL_SECONDS } " ,
55
+ # increase speed of garbage collection
56
+ "GARBAGE_COLLECTOR_INTERVAL_S" : f"{ DEFAULT_GARBAGE_COLLECTOR_DELETION_TIMEOUT_SECONDS } " ,
57
+ },
58
+ )
58
59
59
60
60
61
@pytest .fixture
@@ -68,10 +69,13 @@ def client(
68
69
mock_orphaned_services ,
69
70
redis_client , # this ensure redis is properly cleaned
70
71
):
71
- # config app
72
72
app = create_safe_application ()
73
73
74
+ assert "WEBSERVER_GARBAGE_COLLECTOR" not in app_environment
75
+
74
76
settings = setup_settings (app )
77
+ assert settings .WEBSERVER_GARBAGE_COLLECTOR is not None
78
+ assert settings .WEBSERVER_PROJECTS is not None
75
79
assert settings .WEBSERVER_TAGS is not None
76
80
77
81
# setup app
0 commit comments