Skip to content

Commit 67d8ad8

Browse files
committed
Update test for deleting resource
1 parent 70f9186 commit 67d8ad8

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

tests/aws/services/cloudformation/api/test_changesets.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,18 @@ def test_simple_update_two_resources(
104104

105105
res.destroy()
106106

107-
@markers.aws.needs_fixing
108-
def test_deleting_resource(self, aws_client: ServiceLevelClientFactory, deploy_cfn_template):
107+
@markers.aws.validated
108+
# TODO: the error response is incorrect, however the test is otherwise validated and raises
109+
# an error because the SSM parameter has been deleted (removed from the stack).
110+
@markers.snapshot.skip_snapshot_verify(paths=["$..Error.Message", "$..message"])
111+
@pytest.mark.skipif(
112+
condition=not is_v2_engine() and not is_aws_cloud(), reason="Test fails with the old engine"
113+
)
114+
def test_deleting_resource(
115+
self, aws_client: ServiceLevelClientFactory, deploy_cfn_template, snapshot
116+
):
109117
parameter_name = "my-parameter"
110118
value1 = "foo"
111-
stack_name = f"stack-{short_uid()}"
112119

113120
t1 = {
114121
"Resources": {
@@ -130,20 +137,18 @@ def test_deleting_resource(self, aws_client: ServiceLevelClientFactory, deploy_c
130137
},
131138
}
132139

133-
res = deploy_cfn_template(stack_name=stack_name, template=json.dumps(t1), is_update=False)
140+
stack = deploy_cfn_template(template=json.dumps(t1))
134141
found_value = aws_client.ssm.get_parameter(Name=parameter_name)["Parameter"]["Value"]
135142
assert found_value == value1
136143

137144
t2 = copy.deepcopy(t1)
138145
del t2["Resources"]["MyParameter2"]
139146

140-
deploy_cfn_template(stack_name=stack_name, template=json.dumps(t2), is_update=True)
147+
deploy_cfn_template(stack_name=stack.stack_name, template=json.dumps(t2), is_update=True)
141148
with pytest.raises(ClientError) as exc_info:
142-
aws_client.ssm.get_parameter(Name=parameter_name)["Parameter"]["Value"]
149+
aws_client.ssm.get_parameter(Name=parameter_name)
143150

144-
assert f"Parameter {parameter_name} not found" in str(exc_info.value)
145-
146-
res.destroy()
151+
snapshot.match("get-parameter-error", exc_info.value.response)
147152

148153

149154
@markers.aws.validated

tests/aws/services/cloudformation/api/test_changesets.snapshot.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7268,5 +7268,20 @@
72687268
"before-value": "<name-1>",
72697269
"after-value": "<name-2>"
72707270
}
7271+
},
7272+
"tests/aws/services/cloudformation/api/test_changesets.py::TestUpdates::test_deleting_resource": {
7273+
"recorded-date": "15-04-2025, 15:07:18",
7274+
"recorded-content": {
7275+
"get-parameter-error": {
7276+
"Error": {
7277+
"Code": "ParameterNotFound",
7278+
"Message": ""
7279+
},
7280+
"ResponseMetadata": {
7281+
"HTTPHeaders": {},
7282+
"HTTPStatusCode": 400
7283+
}
7284+
}
7285+
}
72717286
}
72727287
}

tests/aws/services/cloudformation/api/test_changesets.validation.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"tests/aws/services/cloudformation/api/test_changesets.py::TestCaptureUpdateProcess::test_unrelated_changes_update_propagation": {
4242
"last_validated_date": "2025-04-01T16:40:03+00:00"
4343
},
44+
"tests/aws/services/cloudformation/api/test_changesets.py::TestUpdates::test_deleting_resource": {
45+
"last_validated_date": "2025-04-15T15:07:18+00:00"
46+
},
4447
"tests/aws/services/cloudformation/api/test_changesets.py::TestUpdates::test_simple_update_two_resources": {
4548
"last_validated_date": "2025-04-02T10:05:26+00:00"
4649
},

0 commit comments

Comments
 (0)