Skip to content

Commit 8c1c69d

Browse files
committed
add simple test for subnets
1 parent 28c9d82 commit 8c1c69d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

services/autoscaling/tests/unit/test_core_settings.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
$ pytest --external-envfile=.secrets --pdb tests/unit/test_core_settings.py
1010
1111
"""
12+
1213
import datetime
1314
import json
1415
import logging
1516
import os
1617
from typing import Final
1718

1819
import pytest
20+
from common_library.json_serialization import json_dumps
1921
from faker import Faker
2022
from pydantic import ValidationError
2123
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
@@ -72,6 +74,16 @@ def test_settings(app_environment: EnvVarsDict):
7274
assert settings.AUTOSCALING_REDIS
7375

7476

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+
7587
def test_settings_dynamic_mode(enabled_dynamic_mode: EnvVarsDict):
7688
settings = ApplicationSettings.create_from_envs()
7789
assert settings.AUTOSCALING_EC2_ACCESS
@@ -172,7 +184,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_passing_invalid_image_tags( # noqa: N802
172184
)
173185

174186
with caplog.at_level(logging.WARNING):
175-
176187
settings = ApplicationSettings.create_from_envs()
177188
assert settings.AUTOSCALING_EC2_INSTANCES is None
178189

@@ -265,7 +276,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed_with_main_field_env_var(
265276
# NOTE: input captured via EnvSettingsWithAutoDefaultSource
266277
# default env factory -> None
267278
with caplog.at_level(logging.WARNING):
268-
269279
settings = ApplicationSettings.create_from_envs()
270280
assert settings.AUTOSCALING_EC2_INSTANCES is None
271281

@@ -293,7 +303,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed_without_main_field_env_va
293303
# removing any value for AUTOSCALING_EC2_INSTANCES
294304
caplog.clear()
295305
with caplog.at_level(logging.WARNING):
296-
297306
settings = ApplicationSettings.create_from_envs()
298307
assert settings.AUTOSCALING_EC2_INSTANCES is None
299308

@@ -330,7 +339,6 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_invalid_instance_names( # noqa: N802
330339
)
331340
caplog.clear()
332341
with caplog.at_level(logging.WARNING):
333-
334342
settings = ApplicationSettings.create_from_envs()
335343
assert settings.AUTOSCALING_EC2_INSTANCES is None
336344

0 commit comments

Comments
 (0)