99
1010import pytest
1111from aioresponses import aioresponses
12+ from pytest_simcore .helpers .monkeypatch_envs import setenvs_from_dict
1213from pytest_simcore .helpers .typing_env import EnvVarsDict
1314from pytest_simcore .helpers .webserver_login import UserInfoDict
1415from pytest_simcore .helpers .webserver_projects import NewProject , delete_all_projects
4041@pytest .fixture
4142def app_environment (
4243 monkeypatch : pytest .MonkeyPatch ,
43- app_cfg : AppConfigDict ,
4444 app_environment : EnvVarsDict ,
45- monkeypatch_setenv_from_app_config : Callable [[AppConfigDict ], EnvVarsDict ],
4645) -> 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 )
5649
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+ )
5859
5960
6061@pytest .fixture
@@ -68,10 +69,13 @@ def client(
6869 mock_orphaned_services ,
6970 redis_client , # this ensure redis is properly cleaned
7071):
71- # config app
7272 app = create_safe_application ()
7373
74+ assert "WEBSERVER_GARBAGE_COLLECTOR" not in app_environment
75+
7476 settings = setup_settings (app )
77+ assert settings .WEBSERVER_GARBAGE_COLLECTOR is not None
78+ assert settings .WEBSERVER_PROJECTS is not None
7579 assert settings .WEBSERVER_TAGS is not None
7680
7781 # setup app
0 commit comments