Skip to content

Commit

Permalink
@sanderegg review: split tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Nov 12, 2024
1 parent 209be87 commit c955230
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions services/autoscaling/tests/unit/test_core_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,32 @@ def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed( # noqa: N802
# test child settings
with pytest.raises(ValidationError) as err_info:
EC2InstancesSettings.create_from_envs()

assert err_info.value.errors()[0]["loc"] == ("EC2_INSTANCES_ALLOWED_TYPES",)

# now as part of AUTOSCALING_EC2_INSTANCES: EC2InstancesSettings | None

def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed_with_main_field_env_var( # noqa: N802
app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
):
assert os.environ["AUTOSCALING_EC2_INSTANCES"] == "{}"
monkeypatch.setenv("EC2_INSTANCES_ALLOWED_TYPES", "{}")

with pytest.raises(ValidationError) as err_info:
# now as part of AUTOSCALING_EC2_INSTANCES: EC2InstancesSettings | None
with pytest.raises(ValidationError) as exc_before:
ApplicationSettings.create_from_envs(AUTOSCALING_EC2_INSTANCES={})

before = err_info.value.errors()

with pytest.raises(ValidationError) as err_info:
with pytest.raises(ValidationError) as exc_after:
ApplicationSettings.create_from_envs()

assert err_info.value.errors() == before
assert exc_before.value.errors() == exc_after.value.errors()

# removing any value for AUTOSCALING_EC2_INSTANCES

def test_EC2_INSTANCES_ALLOWED_TYPES_empty_not_allowed_without_main_field_env_var( # noqa: N802
app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
):
monkeypatch.delenv("AUTOSCALING_EC2_INSTANCES")

# removing any value for AUTOSCALING_EC2_INSTANCES
settings = ApplicationSettings.create_from_envs()
assert settings.AUTOSCALING_EC2_INSTANCES is None

Expand Down

0 comments on commit c955230

Please sign in to comment.