Skip to content

Commit ffb6195

Browse files
committed
ensures all test settings
1 parent 55c95ea commit ffb6195

File tree

16 files changed

+215
-47
lines changed

16 files changed

+215
-47
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# pylint: disable=unused-variable
2+
# pylint: disable=unused-argument
3+
# pylint: disable=redefined-outer-name
4+
5+
6+
from pytest_simcore.helpers.monkeypatch_envs import (
7+
EnvVarsDict,
8+
)
9+
from simcore_service_agent.core.settings import ApplicationSettings
10+
11+
12+
def test_valid_application_settings(app_environment: EnvVarsDict):
13+
assert app_environment
14+
15+
settings = ApplicationSettings() # type: ignore
16+
assert settings
17+
18+
assert settings == ApplicationSettings.create_from_envs()

services/api-server/tests/unit/test_core_settings.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ def app_environment(
3333

3434

3535
def test_valid_application_settings(app_environment: EnvVarsDict):
36-
"""
37-
We can validate actual .env files (also refered as `repo.config` files) by passing them via the CLI
38-
39-
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
40-
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
41-
42-
"""
4336
assert app_environment
4437

4538
settings = ApplicationSettings() # type: ignore

services/autoscaling/tests/unit/test_core_settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
# pylint: disable=redefined-outer-name
33
# pylint: disable=unused-argument
44
# pylint: disable=unused-variable
5+
"""
6+
We can validate actual .env files (also refered as `repo.config` files) by passing them via the CLI
57
8+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
9+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
10+
11+
"""
612
import datetime
713
import json
814
import logging

services/catalog/tests/unit/test_core_settings.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# pylint: disable=unused-argument
33
# pylint: disable=unused-variable
44
# pylint: disable=too-many-arguments
5+
"""
6+
We can validate actual .env files (also refered as `repo.config` files) by passing them via the CLI
57
8+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
9+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
10+
11+
"""
612

713
from pytest_simcore.helpers.typing_env import EnvVarsDict
814
from simcore_service_catalog.core.settings import ApplicationSettings
915

1016

1117
def test_valid_application_settings(app_environment: EnvVarsDict):
12-
"""
13-
We can validate actual .env files (also refered as `repo.config` files) by passing them via the CLI
14-
15-
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
16-
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
17-
18-
"""
1918
assert app_environment
2019

2120
settings = ApplicationSettings() # type: ignore

services/clusters-keeper/tests/unit/test_core_settings.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import pytest
1010
from aws_library.ec2 import EC2InstanceBootSpecific
1111
from pydantic import ValidationError
12-
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
12+
from pytest_simcore.helpers.monkeypatch_envs import (
13+
EnvVarsDict,
14+
delenvs_from_dict,
15+
setenvs_from_dict,
16+
)
1317
from simcore_service_clusters_keeper.core.settings import ApplicationSettings
1418
from types_aiobotocore_ec2.literals import InstanceTypeType
1519

@@ -110,3 +114,29 @@ def test_valid_primary_custom_tags(
110114
{"PRIMARY_EC2_INSTANCES_CUSTOM_TAGS": json.dumps(valid_tag)},
111115
)
112116
ApplicationSettings.create_from_envs()
117+
118+
119+
def test_valid_application_settings(
120+
monkeypatch: pytest.MonkeyPatch,
121+
external_envfile_dict: EnvVarsDict,
122+
app_environment: EnvVarsDict,
123+
):
124+
"""
125+
We validate actual envfiles (e.g. repo.config files) by passing them via the CLI
126+
127+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
128+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
129+
130+
"""
131+
assert app_environment
132+
if external_envfile_dict:
133+
delenvs_from_dict(monkeypatch, app_environment, raising=False)
134+
return setenvs_from_dict(
135+
monkeypatch,
136+
{**external_envfile_dict},
137+
)
138+
139+
settings = ApplicationSettings() # type: ignore
140+
assert settings
141+
142+
assert settings == ApplicationSettings.create_from_envs()

services/datcore-adapter/tests/unit/test_core_settings.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# pylint: disable=unused-variable
22
# pylint: disable=unused-argument
33
# pylint: disable=redefined-outer-name
4+
"""
5+
We validate actual envfiles (e.g. repo.config files) by passing them via the CLI
6+
7+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
8+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
9+
10+
"""
411

512

613
import pytest
@@ -18,12 +25,10 @@ def app_environment(
1825
app_environment: EnvVarsDict,
1926
external_envfile_dict: EnvVarsDict,
2027
) -> EnvVarsDict:
21-
"""
22-
NOTE: To run against repo.config in osparc-config repo
23-
24-
ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
25-
pytest --external-envfile=.secrets tests/unit/test_core_settings.py
28+
"""OVERRIDES app_environment fixture:
2629
30+
Enables using external envfiles (e.g. repo.config files) to run tests against
31+
within this test module.
2732
"""
2833
if external_envfile_dict:
2934
delenvs_from_dict(monkeypatch, app_environment, raising=False)
@@ -34,9 +39,11 @@ def app_environment(
3439
return app_environment
3540

3641

37-
def test_unit_app_environment(app_environment: EnvVarsDict):
42+
def test_valid_application_settings(app_environment: EnvVarsDict):
3843
assert app_environment
39-
settings = ApplicationSettings.create_from_envs()
40-
print("captured settings: \n", settings.model_dump_json(indent=2))
44+
45+
settings = ApplicationSettings() # type: ignore
46+
assert settings
47+
assert settings == ApplicationSettings.create_from_envs()
4148

4249
assert settings.PENNSIEVE

services/director-v2/tests/unit/test_core_settings.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# pylint:disable=unused-variable
22
# pylint:disable=unused-argument
33
# pylint:disable=redefined-outer-name
4+
"""
5+
We can validate actual .env files (also refered as `repo.config` files) by passing them via the CLI
6+
7+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
8+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
9+
"""
410

511
from typing import Any
612

@@ -27,7 +33,7 @@ def _get_backend_type_options() -> set[str]:
2733

2834
def test_supported_backends_did_not_change() -> None:
2935
_EXPECTED = {"AWS", "CEPH", "MINIO"}
30-
assert _EXPECTED == _get_backend_type_options(), (
36+
assert _get_backend_type_options() == _EXPECTED, (
3137
"Backend configuration change, please code support for "
3238
"it in volumes_resolver -> _get_s3_volume_driver_config. "
3339
"When done, adjust above list."

services/director/tests/unit/test_core_settings.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# pylint: disable=unused-argument
33
# pylint: disable=unused-variable
44
# pylint: disable=too-many-arguments
5+
"""
6+
We validate actual envfiles (e.g. repo.config files) by passing them via the CLI
7+
8+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
9+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
10+
11+
"""
512

613

714
import datetime
@@ -38,13 +45,6 @@ def app_environment(
3845

3946

4047
def test_valid_application_settings(app_environment: EnvVarsDict):
41-
"""
42-
We validate actual envfiles (e.g. repo.config files) by passing them via the CLI
43-
44-
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
45-
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
46-
47-
"""
4848
settings = ApplicationSettings() # type: ignore
4949
assert settings
5050

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# pylint: disable=unused-variable
2+
# pylint: disable=unused-argument
3+
# pylint: disable=redefined-outer-name
4+
"""
5+
We validate actual envfiles (e.g. repo.config files) by passing them via the CLI
6+
7+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
8+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
9+
10+
"""
11+
12+
13+
import pytest
14+
from pytest_simcore.helpers.monkeypatch_envs import (
15+
EnvVarsDict,
16+
delenvs_from_dict,
17+
setenvs_from_dict,
18+
)
19+
from simcore_service_dynamic_scheduler.core.settings import ApplicationSettings
20+
21+
22+
@pytest.fixture
23+
def app_environment(
24+
monkeypatch: pytest.MonkeyPatch,
25+
app_environment: EnvVarsDict,
26+
external_envfile_dict: EnvVarsDict,
27+
) -> EnvVarsDict:
28+
"""OVERRIDES app_environment fixture:
29+
30+
Enables using external envfiles (e.g. repo.config files) to run tests against
31+
within this test module.
32+
"""
33+
if external_envfile_dict:
34+
delenvs_from_dict(monkeypatch, app_environment, raising=False)
35+
return setenvs_from_dict(
36+
monkeypatch,
37+
{**external_envfile_dict},
38+
)
39+
return app_environment
40+
41+
42+
def test_valid_application_settings(app_environment: EnvVarsDict):
43+
assert app_environment
44+
45+
settings = ApplicationSettings() # type: ignore
46+
assert settings
47+
assert settings == ApplicationSettings.create_from_envs()

services/efs-guardian/tests/unit/test_core_settings.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# pylint: disable=redefined-outer-name
22
# pylint: disable=unused-argument
33
# pylint: disable=unused-variable
4+
"""
5+
We can validate actual .env files (also refered as `repo.config` files) by passing them via the CLI
46
7+
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
8+
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
9+
10+
"""
511

612
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict
713
from simcore_service_efs_guardian.core.settings import ApplicationSettings
814

915

10-
def test_settings(app_environment: EnvVarsDict):
11-
"""
12-
We validate actual envfiles (e.g. repo.config files) by passing them via the CLI
13-
14-
$ ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
15-
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
16+
def test_valid_application_settings(app_environment: EnvVarsDict):
17+
assert app_environment
1618

17-
"""
1819
settings = ApplicationSettings() # type: ignore
1920
assert settings
2021

0 commit comments

Comments
 (0)