Skip to content

Commit

Permalink
Parametrize test_get_azs_function
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrw committed Apr 17, 2024
1 parent e3e67a6 commit cd54f9b
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 13 deletions.
21 changes: 18 additions & 3 deletions tests/aws/services/cloudformation/test_template_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import yaml

from localstack.aws.api.lambda_ import Runtime
from localstack.constants import AWS_REGION_US_EAST_1
from localstack.services.cloudformation.engine.yaml_parser import parse_yaml
from localstack.testing.aws.cloudformation_utils import load_template_file, load_template_raw
from localstack.testing.pytest import markers
Expand Down Expand Up @@ -234,24 +233,40 @@ def test_cidr_function(self, deploy_cfn_template):

assert deployed.outputs["Address"] == "10.0.0.0/24"

@pytest.mark.parametrize(
"region",
[
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ap-southeast-2",
"ap-northeast-1",
"eu-central-1",
"eu-west-1",
],
)
@markers.aws.validated
def test_get_azs_function(self, deploy_cfn_template, snapshot):
def test_get_azs_function(self, deploy_cfn_template, region, aws_client_factory, snapshot):
"""
TODO parametrize this test.
For that we need to be able to parametrize the client region. The docs show the we should be
able to put any region in the parameters but it doesn't work. It only accepts the same region from the client config
if you put anything else it just returns an empty list.
"""
snapshot.add_transformer(snapshot.transform.regex(region, "<region>"))

template_path = os.path.join(
os.path.dirname(__file__), "../../templates/functions_get_azs.yml"
)

aws_client = aws_client_factory(region_name=region)
deployed = deploy_cfn_template(
template_path=template_path,
custom_aws_client=aws_client,
parameters={"DeployRegion": region},
)

snapshot.add_transformer(snapshot.transform.regex(AWS_REGION_US_EAST_1, "<region>"))
snapshot.match("azs", deployed.outputs["Zones"].split(";"))

@markers.aws.validated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,19 @@
}
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function": {
"recorded-date": "03-04-2024, 07:12:29",
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-west-2]": {
"recorded-date": "17-04-2024, 10:25:14",
"recorded-content": {
"azs": [
"<region>a",
"<region>b",
"<region>c",
"<region>d"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-east-1]": {
"recorded-date": "17-04-2024, 10:24:29",
"recorded-content": {
"azs": [
"<region>a",
Expand All @@ -612,5 +623,64 @@
"<region>f"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-east-2]": {
"recorded-date": "17-04-2024, 10:24:45",
"recorded-content": {
"azs": [
"<region>a",
"<region>b",
"<region>c"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-west-1]": {
"recorded-date": "17-04-2024, 10:24:59",
"recorded-content": {
"azs": [
"<region>b",
"<region>c"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[ap-southeast-2]": {
"recorded-date": "17-04-2024, 10:25:33",
"recorded-content": {
"azs": [
"<region>a",
"<region>b",
"<region>c"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[ap-northeast-1]": {
"recorded-date": "17-04-2024, 10:25:52",
"recorded-content": {
"azs": [
"<region>a",
"<region>c",
"<region>d"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[eu-central-1]": {
"recorded-date": "17-04-2024, 10:26:09",
"recorded-content": {
"azs": [
"<region>a",
"<region>b",
"<region>c"
]
}
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[eu-west-1]": {
"recorded-date": "17-04-2024, 10:26:24",
"recorded-content": {
"azs": [
"<region>a",
"<region>b",
"<region>c"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function": {
"last_validated_date": "2024-04-03T07:12:29+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[ap-northeast-1]": {
"last_validated_date": "2024-04-17T10:25:52+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[ap-southeast-2]": {
"last_validated_date": "2024-04-17T10:25:33+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[eu-central-1]": {
"last_validated_date": "2024-04-17T10:26:09+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[eu-west-1]": {
"last_validated_date": "2024-04-17T10:26:24+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-east-1]": {
"last_validated_date": "2024-04-17T10:24:29+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-east-2]": {
"last_validated_date": "2024-04-17T10:24:45+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-west-1]": {
"last_validated_date": "2024-04-17T10:24:59+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestIntrinsicFunctions::test_get_azs_function[us-west-2]": {
"last_validated_date": "2024-04-17T10:25:14+00:00"
},
"tests/aws/services/cloudformation/test_template_engine.py::TestMacros::test_capabilities_requirements": {
"last_validated_date": "2023-01-30T19:15:46+00:00"
},
Expand Down
8 changes: 0 additions & 8 deletions tests/aws/templates/functions_get_azs.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
Parameters:
DeployRegion:
Type: String
Default: us-east-1

Conditions:
DeployInUSEast1:
Fn::Equals:
- !Ref DeployRegion
- us-east-1

Resources:
SsmParameter:
Type: AWS::SSM::Parameter
Condition: DeployInUSEast1
Properties:
Type: String
Value:
Expand Down

0 comments on commit cd54f9b

Please sign in to comment.