|
9 | 9 | $ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py |
10 | 10 |
|
11 | 11 | """ |
| 12 | + |
12 | 13 | import datetime |
13 | 14 | import json |
14 | 15 | import logging |
15 | 16 | import os |
16 | 17 | from typing import Final |
17 | 18 |
|
18 | 19 | import pytest |
| 20 | +from common_library.json_serialization import json_dumps |
19 | 21 | from faker import Faker |
20 | 22 | from pydantic import ValidationError |
21 | 23 | from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict |
@@ -72,6 +74,16 @@ def test_settings(app_environment: EnvVarsDict): |
72 | 74 | assert settings.AUTOSCALING_REDIS |
73 | 75 |
|
74 | 76 |
|
| 77 | +def test_settings_multiple_subnets( |
| 78 | + app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch, faker: Faker |
| 79 | +): |
| 80 | + subnets = [faker.pystr() for _ in range(3)] |
| 81 | + monkeypatch.setenv("EC2_INSTANCES_SUBNET_IDS", json_dumps(subnets)) |
| 82 | + settings = ApplicationSettings.create_from_envs() |
| 83 | + assert settings.AUTOSCALING_EC2_INSTANCES |
| 84 | + assert subnets == settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_IDS |
| 85 | + |
| 86 | + |
75 | 87 | def test_settings_dynamic_mode(enabled_dynamic_mode: EnvVarsDict): |
76 | 88 | settings = ApplicationSettings.create_from_envs() |
77 | 89 | assert settings.AUTOSCALING_EC2_ACCESS |
@@ -172,7 +184,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_passing_invalid_image_tags( # noqa: N802 |
172 | 184 | ) |
173 | 185 |
|
174 | 186 | with caplog.at_level(logging.WARNING): |
175 | | - |
176 | 187 | settings = ApplicationSettings.create_from_envs() |
177 | 188 | assert settings.AUTOSCALING_EC2_INSTANCES is None |
178 | 189 |
|
@@ -265,7 +276,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed_with_main_field_env_var( |
265 | 276 | # NOTE: input captured via EnvSettingsWithAutoDefaultSource |
266 | 277 | # default env factory -> None |
267 | 278 | with caplog.at_level(logging.WARNING): |
268 | | - |
269 | 279 | settings = ApplicationSettings.create_from_envs() |
270 | 280 | assert settings.AUTOSCALING_EC2_INSTANCES is None |
271 | 281 |
|
@@ -293,7 +303,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed_without_main_field_env_va |
293 | 303 | # removing any value for AUTOSCALING_EC2_INSTANCES |
294 | 304 | caplog.clear() |
295 | 305 | with caplog.at_level(logging.WARNING): |
296 | | - |
297 | 306 | settings = ApplicationSettings.create_from_envs() |
298 | 307 | assert settings.AUTOSCALING_EC2_INSTANCES is None |
299 | 308 |
|
@@ -330,7 +339,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_invalid_instance_names( # noqa: N802 |
330 | 339 | ) |
331 | 340 | caplog.clear() |
332 | 341 | with caplog.at_level(logging.WARNING): |
333 | | - |
334 | 342 | settings = ApplicationSettings.create_from_envs() |
335 | 343 | assert settings.AUTOSCALING_EC2_INSTANCES is None |
336 | 344 |
|
|
0 commit comments