Skip to content

Commit 282d044

Browse files
committed
Fixing tests on setup_settings
1 parent 4a4c338 commit 282d044

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

services/web/server/src/simcore_service_webserver/rest_handlers.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ async def check_action(request: web.Request):
5454

5555
async def get_config(request: web.Request):
5656
"""
57-
This entrypoint aims to provide an extra configuration mechanism for
58-
the front-end app.
57+
This entrypoint aims to provide an extra configuration mechanism for
58+
the front-end app.
5959
60-
Some of the server configuration can be forwarded to the front-end here
60+
Some of the server configuration can be forwarded to the front-end here
6161
62-
Example use case: the front-end app is served to the client. Then the user wants to
63-
register but the server has been setup to require an invitation. This option is setup
64-
at runtime and the front-end can only get it upon request to /config
62+
Example use case: the front-end app is served to the client. Then the user wants to
63+
register but the server has been setup to require an invitation. This option is setup
64+
at runtime and the front-end can only get it upon request to /config
6565
"""
6666
await extract_and_validate(request)
6767

@@ -72,6 +72,6 @@ async def get_config(request: web.Request):
7272
data = {
7373
"invitation_required": login_cfg.get("registration_invitation_required", False)
7474
}
75-
data.update( app[APP_SETTINGS_KEY].public_dict() )
75+
data.update(request.app[APP_SETTINGS_KEY].public_dict())
7676

7777
return data

services/web/server/src/simcore_service_webserver/settings.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
TODO: pydantic settings comming soon and replacing trafaret
33
44
"""
5+
import logging
6+
from typing import Dict, Optional
7+
58
from aiohttp import web
69
from pydantic import BaseSettings
7-
from pprint import pprint
8-
from typing import Dict
910

1011
APP_SETTINGS_KEY = f"{__name__ }.build_time_settings"
1112

13+
log = logging.getLogger(__name__)
14+
1215

1316
class BuildTimeSettings(BaseSettings):
1417
# All these settings are defined in the Dockerfile at build-image time
@@ -33,7 +36,7 @@ class Config:
3336
def public_dict(self) -> Dict:
3437
""" Data publicaly available """
3538
return self.dict(
36-
include=["vsc_url", "vsc_ref", "build_date"],
39+
include={"vsc_url", "vsc_ref", "build_date"},
3740
exclude_unset=True,
3841
exclude_none=True,
3942
)

services/web/server/src/simcore_service_webserver/statics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def write_statics_file(app: web.Application, directory: Path) -> None:
6565
statics = {}
6666
statics["stackName"] = os.environ.get("SWARM_STACK_NAME")
6767
statics["buildDate"] = app[APP_SETTINGS_KEY].build_date
68-
statics.udpate(app[APP_SETTINGS_KEY].public_dict())
68+
statics.update(app[APP_SETTINGS_KEY].public_dict())
6969

7070
with open(directory / "statics.json", "wt") as fh:
7171
json.dump(statics, fh)

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

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from simcore_service_webserver.resources import resources
1717
from simcore_service_webserver.rest import setup_rest
1818
from simcore_service_webserver.security import setup_security
19+
from simcore_service_webserver.settings import setup_settings
1920

2021

2122
@pytest.fixture
@@ -43,7 +44,9 @@ async def slow_handler(request: web.Request):
4344
"main": server_kwargs,
4445
"rest": {"enabled": True, "version": api_version_prefix},
4546
}
47+
4648
# activates only security+restAPI sub-modules
49+
setup_settings(app)
4750
setup_security(app)
4851
setup_rest(app)
4952

services/web/server/tests/unit/with_dbs/fast/test_access_to_studies.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from simcore_service_webserver.rest import setup_rest
2929
from simcore_service_webserver.security import setup_security
3030
from simcore_service_webserver.session import setup_session
31+
from simcore_service_webserver.settings import setup_settings
3132
from simcore_service_webserver.statics import setup_statics
3233
from simcore_service_webserver.studies_access import setup_studies_access
3334
from simcore_service_webserver.users import setup_users
@@ -77,6 +78,7 @@ def client(loop, aiohttp_client, app_cfg, postgres_db, qx_client_outdir, monkeyp
7778

7879
app = create_safe_application(cfg)
7980

81+
setup_settings(app)
8082
setup_statics(app)
8183
setup_db(app)
8284
setup_session(app)
@@ -98,7 +100,7 @@ def client(loop, aiohttp_client, app_cfg, postgres_db, qx_client_outdir, monkeyp
98100

99101
@pytest.fixture
100102
async def logged_user(client): # , role: UserRole):
101-
""" adds a user in db and logs in with client
103+
"""adds a user in db and logs in with client
102104
103105
NOTE: role fixture is defined as a parametrization below
104106
"""

0 commit comments

Comments
 (0)