Skip to content

Commit 1a6f9dd

Browse files
authored
chore: improve remaining tests snapshots (#12373)
1 parent 4f210f8 commit 1a6f9dd

18 files changed

+535
-162
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,15 @@ def test_execute_change_set(
420420
@markers.aws.validated
421421
def test_delete_change_set_exception(snapshot, aws_client):
422422
"""test error cases when trying to delete a change set"""
423-
with pytest.raises(Exception) as e1:
423+
with pytest.raises(ClientError) as e1:
424424
aws_client.cloudformation.delete_change_set(
425425
StackName="nostack", ChangeSetName="DoesNotExist"
426426
)
427-
snapshot.match("e1", e1)
427+
snapshot.match("e1", e1.value.response)
428428

429-
with pytest.raises(Exception) as e2:
429+
with pytest.raises(ClientError) as e2:
430430
aws_client.cloudformation.delete_change_set(ChangeSetName="DoesNotExist")
431-
snapshot.match("e2", e2)
431+
snapshot.match("e2", e2.value.response)
432432

433433

434434
@markers.aws.validated

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,36 @@
166166
}
167167
},
168168
"tests/aws/services/cloudformation/api/test_changesets.py::test_describe_change_set_nonexisting": {
169-
"recorded-date": "11-08-2022, 13:22:01",
169+
"recorded-date": "11-03-2025, 19:12:57",
170170
"recorded-content": {
171171
"exception": "An error occurred (ValidationError) when calling the DescribeChangeSet operation: Stack [somestack] does not exist"
172172
}
173173
},
174174
"tests/aws/services/cloudformation/api/test_changesets.py::test_delete_change_set_exception": {
175-
"recorded-date": "11-08-2022, 14:07:38",
175+
"recorded-date": "11-03-2025, 19:13:48",
176176
"recorded-content": {
177-
"e1": "<ExceptionInfo ClientError('An error occurred (ValidationError) when calling the DeleteChangeSet operation: Stack [nostack] does not exist') tblen=3>",
178-
"e2": "<ExceptionInfo ClientError('An error occurred (ValidationError) when calling the DeleteChangeSet operation: StackName must be specified if ChangeSetName is not specified as an ARN.') tblen=3>"
177+
"e1": {
178+
"Error": {
179+
"Code": "ValidationError",
180+
"Message": "Stack [nostack] does not exist",
181+
"Type": "Sender"
182+
},
183+
"ResponseMetadata": {
184+
"HTTPHeaders": {},
185+
"HTTPStatusCode": 400
186+
}
187+
},
188+
"e2": {
189+
"Error": {
190+
"Code": "ValidationError",
191+
"Message": "StackName must be specified if ChangeSetName is not specified as an ARN.",
192+
"Type": "Sender"
193+
},
194+
"ResponseMetadata": {
195+
"HTTPHeaders": {},
196+
"HTTPStatusCode": 400
197+
}
198+
}
179199
}
180200
},
181201
"tests/aws/services/cloudformation/api/test_changesets.py::test_name_conflicts": {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"last_validated_date": "2023-11-22T07:49:15+00:00"
1313
},
1414
"tests/aws/services/cloudformation/api/test_changesets.py::test_delete_change_set_exception": {
15-
"last_validated_date": "2022-08-11T12:07:38+00:00"
15+
"last_validated_date": "2025-03-11T19:13:48+00:00"
1616
},
1717
"tests/aws/services/cloudformation/api/test_changesets.py::test_deleted_changeset": {
1818
"last_validated_date": "2022-08-11T09:11:47+00:00"
1919
},
2020
"tests/aws/services/cloudformation/api/test_changesets.py::test_describe_change_set_nonexisting": {
21-
"last_validated_date": "2022-08-11T11:22:01+00:00"
21+
"last_validated_date": "2025-03-11T19:12:57+00:00"
2222
},
2323
"tests/aws/services/cloudformation/api/test_changesets.py::test_describe_change_set_with_similarly_named_stacks": {
2424
"last_validated_date": "2024-03-06T13:56:47+00:00"

tests/aws/services/events/test_archive_and_replay.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from datetime import datetime, timedelta, timezone
33

44
import pytest
5+
from botocore.exceptions import ClientError
56

67
from localstack.testing.pytest import markers
78
from localstack.utils.strings import short_uid
@@ -272,7 +273,7 @@ def test_create_archive_error_duplicate(
272273
EventPattern=json.dumps(TEST_EVENT_PATTERN),
273274
RetentionDays=1,
274275
)
275-
with pytest.raises(Exception) as error:
276+
with pytest.raises(ClientError) as error:
276277
aws_client.events.create_archive(
277278
ArchiveName=archive_name,
278279
EventSourceArn=event_bus_arn,
@@ -282,7 +283,7 @@ def test_create_archive_error_duplicate(
282283
)
283284

284285
snapshot.add_transformer([snapshot.transform.regex(archive_name, "<archive-name>")])
285-
snapshot.match("create-archive-duplicate-error", error)
286+
snapshot.match("create-archive-duplicate-error", error.value.response)
286287

287288
@markers.aws.validated
288289
@pytest.mark.skipif(is_old_provider(), reason="not supported by the old provider")
@@ -291,7 +292,7 @@ def test_create_archive_error_unknown_event_bus(self, aws_client, snapshot):
291292
non_existing_event_bus_arn = (
292293
f"arn:aws:events:us-east-1:123456789012:event-bus/{not_existing_event_bus_name}"
293294
)
294-
with pytest.raises(Exception) as error:
295+
with pytest.raises(ClientError) as error:
295296
aws_client.events.create_archive(
296297
ArchiveName="test-archive",
297298
EventSourceArn=non_existing_event_bus_arn,
@@ -303,19 +304,19 @@ def test_create_archive_error_unknown_event_bus(self, aws_client, snapshot):
303304
snapshot.add_transformer(
304305
[snapshot.transform.regex(not_existing_event_bus_name, "<event-bus-name>")]
305306
)
306-
snapshot.match("create-archive-unknown-event-bus-error", error)
307+
snapshot.match("create-archive-unknown-event-bus-error", error.value.response)
307308

308309
@markers.aws.validated
309310
@pytest.mark.skipif(is_old_provider(), reason="not supported by the old provider")
310311
def test_describe_archive_error_unknown_archive(self, aws_client, snapshot):
311312
not_existing_archive_name = f"doesnotexist-{short_uid()}"
312-
with pytest.raises(Exception) as error:
313+
with pytest.raises(ClientError) as error:
313314
aws_client.events.describe_archive(ArchiveName=not_existing_archive_name)
314315

315316
snapshot.add_transformer(
316317
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
317318
)
318-
snapshot.match("describe-archive-unknown-archive-error", error)
319+
snapshot.match("describe-archive-unknown-archive-error", error.value.response)
319320

320321
@markers.aws.validated
321322
@pytest.mark.skipif(is_old_provider(), reason="not supported by the old provider")
@@ -326,37 +327,37 @@ def test_list_archive_error_unknown_source_arn(
326327
non_existing_event_bus_arn = (
327328
f"arn:aws:events:{region_name}:{account_id}:event-bus/{not_existing_event_bus_name}"
328329
)
329-
with pytest.raises(Exception) as error:
330+
with pytest.raises(ClientError) as error:
330331
aws_client.events.list_archives(EventSourceArn=non_existing_event_bus_arn)
331332

332333
snapshot.add_transformer(
333334
[snapshot.transform.regex(not_existing_event_bus_name, "<event-bus-name>")]
334335
)
335-
snapshot.match("list-archives-unknown-event-bus-error", error)
336+
snapshot.match("list-archives-unknown-event-bus-error", error.value.response)
336337

337338
@markers.aws.validated
338339
@pytest.mark.skip(reason="not possible to test with localstack")
339340
def test_update_archive_error_unknown_archive(self, aws_client, snapshot):
340341
not_existing_archive_name = f"doesnotexist-{short_uid()}"
341-
with pytest.raises(Exception) as error:
342+
with pytest.raises(ClientError) as error:
342343
aws_client.events.update_archive(ArchiveName=not_existing_archive_name)
343344

344345
snapshot.add_transformer(
345346
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
346347
)
347-
snapshot.match("update-archive-unknown-archive-error", error)
348+
snapshot.match("update-archive-unknown-archive-error", error.value.response)
348349

349350
@markers.aws.validated
350351
@pytest.mark.skipif(is_old_provider(), reason="not supported by the old provider")
351352
def test_delete_archive_error_unknown_archive(self, aws_client, snapshot):
352353
not_existing_archive_name = f"doesnotexist-{short_uid()}"
353-
with pytest.raises(Exception) as error:
354+
with pytest.raises(ClientError) as error:
354355
aws_client.events.delete_archive(ArchiveName=not_existing_archive_name)
355356

356357
snapshot.add_transformer(
357358
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
358359
)
359-
snapshot.match("delete-archive-unknown-archive-error", error)
360+
snapshot.match("delete-archive-unknown-archive-error", error.value.response)
360361

361362

362363
class TestReplay:
@@ -669,7 +670,7 @@ def test_start_replay_error_unknown_event_bus(
669670
end_time = datetime.now(timezone.utc)
670671

671672
replay_name = f"test-replay-{short_uid()}"
672-
with pytest.raises(Exception) as error:
673+
with pytest.raises(ClientError) as error:
673674
aws_client.events.start_replay(
674675
ReplayName=replay_name,
675676
Description="description of the replay",
@@ -684,11 +685,11 @@ def test_start_replay_error_unknown_event_bus(
684685
snapshot.add_transformer(
685686
[snapshot.transform.regex(not_existing_event_bus_name, "<event-bus-name>")]
686687
)
687-
snapshot.match("start-replay-unknown-event-bus-error", error)
688+
snapshot.match("start-replay-unknown-event-bus-error", error.value.response)
688689

689690
event_bus_arn = events_create_event_bus(Name=not_existing_event_bus_name)["EventBusArn"]
690691

691-
with pytest.raises(Exception) as error:
692+
with pytest.raises(ClientError) as error:
692693
aws_client.events.start_replay(
693694
ReplayName=replay_name,
694695
Description="description of the replay",
@@ -700,7 +701,7 @@ def test_start_replay_error_unknown_event_bus(
700701
}, # the destination must be the exact same event bus the archive is created for
701702
)
702703

703-
snapshot.match("start-replay-wrong-event-bus-error", error)
704+
snapshot.match("start-replay-wrong-event-bus-error", error.value.response)
704705

705706
@markers.aws.validated
706707
def test_start_replay_error_unknown_archive(
@@ -709,7 +710,7 @@ def test_start_replay_error_unknown_archive(
709710
not_existing_archive_name = f"doesnotexist-{short_uid()}"
710711
start_time = datetime.now(timezone.utc) - timedelta(minutes=1)
711712
end_time = datetime.now(timezone.utc)
712-
with pytest.raises(Exception) as error:
713+
with pytest.raises(ClientError) as error:
713714
aws_client.events.start_replay(
714715
ReplayName="test-replay",
715716
Description="description of the replay",
@@ -724,7 +725,7 @@ def test_start_replay_error_unknown_archive(
724725
snapshot.add_transformer(
725726
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
726727
)
727-
snapshot.match("start-replay-unknown-archive-error", error)
728+
snapshot.match("start-replay-unknown-archive-error", error.value.response)
728729

729730
@markers.aws.validated
730731
def test_start_replay_error_duplicate_name_same_archive(
@@ -751,7 +752,7 @@ def test_start_replay_error_duplicate_name_same_archive(
751752
},
752753
)
753754

754-
with pytest.raises(Exception) as error:
755+
with pytest.raises(ClientError) as error:
755756
aws_client.events.start_replay(
756757
ReplayName=replay_name,
757758
Description="description of the replay",
@@ -764,7 +765,7 @@ def test_start_replay_error_duplicate_name_same_archive(
764765
)
765766

766767
snapshot.add_transformer([snapshot.transform.regex(replay_name, "<replay-name>")])
767-
snapshot.match("start-replay-duplicate-error", error)
768+
snapshot.match("start-replay-duplicate-error", error.value.response)
768769

769770
@markers.aws.validated
770771
def test_start_replay_error_duplicate_different_archive(
@@ -800,7 +801,7 @@ def test_start_replay_error_duplicate_different_archive(
800801
},
801802
)
802803

803-
with pytest.raises(Exception) as error:
804+
with pytest.raises(ClientError) as error:
804805
aws_client.events.start_replay(
805806
ReplayName=replay_name,
806807
Description="description of the replay",
@@ -813,7 +814,7 @@ def test_start_replay_error_duplicate_different_archive(
813814
)
814815

815816
snapshot.add_transformer([snapshot.transform.regex(replay_name, "<replay-name>")])
816-
snapshot.match("start-replay-duplicate-error", error)
817+
snapshot.match("start-replay-duplicate-error", error.value.response)
817818

818819
@markers.aws.validated
819820
@pytest.mark.skipif(is_old_provider(), reason="not supported by the old provider")
@@ -833,7 +834,7 @@ def test_start_replay_error_invalid_end_time(
833834
)
834835

835836
replay_name = f"test-replay-{short_uid()}"
836-
with pytest.raises(Exception) as error:
837+
with pytest.raises(ClientError) as error:
837838
aws_client.events.start_replay(
838839
ReplayName=replay_name,
839840
Description="description of the replay",
@@ -845,7 +846,7 @@ def test_start_replay_error_invalid_end_time(
845846
},
846847
)
847848

848-
snapshot.match("start-replay-invalid-end-time-error", error)
849+
snapshot.match("start-replay-invalid-end-time-error", error.value.response)
849850

850851
@markers.aws.validated
851852
@pytest.mark.skip(reason="currently no concurrency for replays in localstack")
@@ -881,7 +882,7 @@ def tests_concurrency_error_too_many_active_replays(
881882
)
882883

883884
# only 10 replays are allowed to be in state STARTING or RUNNING at the same time
884-
with pytest.raises(Exception) as error:
885+
with pytest.raises(ClientError) as error:
885886
replay_name = f"{replay_name_prefix}-test-replay-{num_replays}"
886887
aws_client.events.start_replay(
887888
ReplayName=replay_name,
@@ -901,15 +902,15 @@ def tests_concurrency_error_too_many_active_replays(
901902
snapshot.transform.jsonpath("$..NextToken", "next_token"),
902903
]
903904
)
904-
snapshot.match("list-replays-with-limit", error)
905+
snapshot.match("list-replays-with-limit", error.value.response)
905906

906907
@markers.aws.validated
907908
def test_describe_replay_error_unknown_replay(self, aws_client, snapshot):
908909
not_existing_replay_name = f"doesnotexist-{short_uid()}"
909-
with pytest.raises(Exception) as error:
910+
with pytest.raises(ClientError) as error:
910911
aws_client.events.describe_replay(ReplayName=not_existing_replay_name)
911912

912913
snapshot.add_transformer(
913914
[snapshot.transform.regex(not_existing_replay_name, "<replay-name>")]
914915
)
915-
snapshot.match("describe-replay-unknown-replay-error", error)
916+
snapshot.match("describe-replay-unknown-replay-error", error.value.response)

0 commit comments

Comments
 (0)