|
3 | 3 | # pylint: disable=unused-variable |
4 | 4 | # pylint: disable=too-many-arguments |
5 | 5 |
|
6 | | -import os |
7 | 6 | from collections.abc import AsyncIterator |
8 | 7 | from pathlib import Path |
9 | 8 |
|
|
13 | 12 | from fastapi import FastAPI |
14 | 13 | from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict |
15 | 14 | from pytest_simcore.helpers.typing_env import EnvVarsDict |
16 | | -from simcore_service_director import config, resources |
17 | 15 | from simcore_service_director.core.application import create_app |
18 | 16 | from simcore_service_director.core.settings import ApplicationSettings |
19 | 17 |
|
@@ -59,45 +57,56 @@ def common_schemas_specs_dir(osparc_simcore_root_dir: Path) -> Path: |
59 | 57 | return specs_dir |
60 | 58 |
|
61 | 59 |
|
62 | | -@pytest.fixture |
63 | | -def configure_schemas_location( |
64 | | - installed_package_dir: Path, common_schemas_specs_dir: Path |
65 | | -) -> None: |
66 | | - config.NODE_SCHEMA_LOCATION = str( |
67 | | - common_schemas_specs_dir / "node-meta-v0.0.1.json" |
68 | | - ) |
69 | | - resources.RESOURCE_NODE_SCHEMA = os.path.relpath( |
70 | | - config.NODE_SCHEMA_LOCATION, installed_package_dir |
71 | | - ) |
72 | | - |
73 | | - |
74 | 60 | @pytest.fixture(scope="session") |
75 | | -def configure_swarm_stack_name() -> None: |
76 | | - config.SWARM_STACK_NAME = "test_stack" |
| 61 | +def configure_swarm_stack_name(monkeypatch: pytest.MonkeyPatch) -> EnvVarsDict: |
| 62 | + return setenvs_from_dict(monkeypatch, envs={"SWARM_STACK_NAME": "test_stack"}) |
77 | 63 |
|
78 | 64 |
|
79 | 65 | @pytest.fixture |
80 | | -def configure_registry_access(docker_registry: str) -> None: |
81 | | - config.REGISTRY_URL = docker_registry |
82 | | - config.REGISTRY_PATH = docker_registry |
83 | | - config.REGISTRY_SSL = False |
84 | | - config.DIRECTOR_REGISTRY_CACHING = False |
| 66 | +def configure_registry_access( |
| 67 | + monkeypatch: pytest.MonkeyPatch, docker_registry: str |
| 68 | +) -> EnvVarsDict: |
| 69 | + return setenvs_from_dict( |
| 70 | + monkeypatch, |
| 71 | + envs={ |
| 72 | + "REGISTRY_URL": docker_registry, |
| 73 | + "REGISTRY_PATH": docker_registry, |
| 74 | + "REGISTRY_SSL": False, |
| 75 | + "DIRECTOR_REGISTRY_CACHING": False, |
| 76 | + }, |
| 77 | + ) |
85 | 78 |
|
86 | 79 |
|
87 | 80 | @pytest.fixture(scope="session") |
88 | | -def configure_custom_registry(pytestconfig: pytest.Config) -> None: |
| 81 | +def configure_custom_registry( |
| 82 | + monkeypatch: pytest.MonkeyPatch, pytestconfig: pytest.Config |
| 83 | +) -> EnvVarsDict: |
89 | 84 | # to set these values call |
90 | 85 | # pytest --registry_url myregistry --registry_user username --registry_pw password |
91 | | - config.REGISTRY_URL = pytestconfig.getoption("registry_url") |
92 | | - config.REGISTRY_AUTH = True |
93 | | - config.REGISTRY_USER = pytestconfig.getoption("registry_user") |
94 | | - config.REGISTRY_PW = pytestconfig.getoption("registry_pw") |
95 | | - config.DIRECTOR_REGISTRY_CACHING = False |
| 86 | + registry_url = pytestconfig.getoption("registry_url") |
| 87 | + assert registry_url |
| 88 | + assert isinstance(registry_url, str) |
| 89 | + registry_user = pytestconfig.getoption("registry_user") |
| 90 | + assert registry_user |
| 91 | + assert isinstance(registry_user, str) |
| 92 | + registry_pw = pytestconfig.getoption("registry_pw") |
| 93 | + assert registry_pw |
| 94 | + assert isinstance(registry_pw, str) |
| 95 | + return setenvs_from_dict( |
| 96 | + monkeypatch, |
| 97 | + envs={ |
| 98 | + "REGISTRY_URL": registry_url, |
| 99 | + "REGISTRY_AUTH": True, |
| 100 | + "REGISTRY_USER": registry_user, |
| 101 | + "REGISTRY_PW": registry_pw, |
| 102 | + "REGISTRY_SSL": False, |
| 103 | + "DIRECTOR_REGISTRY_CACHING": False, |
| 104 | + }, |
| 105 | + ) |
96 | 106 |
|
97 | 107 |
|
98 | 108 | @pytest.fixture |
99 | 109 | def api_version_prefix() -> str: |
100 | | - assert "v0" in resources.listdir(resources.RESOURCE_OPENAPI_ROOT) |
101 | 110 | return "v0" |
102 | 111 |
|
103 | 112 |
|
|
0 commit comments