Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/aws/services/cloudformation/api/test_changesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ def test_execute_change_set(
@markers.aws.validated
def test_delete_change_set_exception(snapshot, aws_client):
"""test error cases when trying to delete a change set"""
with pytest.raises(Exception) as e1:
with pytest.raises(ClientError) as e1:
aws_client.cloudformation.delete_change_set(
StackName="nostack", ChangeSetName="DoesNotExist"
)
snapshot.match("e1", e1)
snapshot.match("e1", e1.value.response)

with pytest.raises(Exception) as e2:
with pytest.raises(ClientError) as e2:
aws_client.cloudformation.delete_change_set(ChangeSetName="DoesNotExist")
snapshot.match("e2", e2)
snapshot.match("e2", e2.value.response)


@markers.aws.validated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,36 @@
}
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_describe_change_set_nonexisting": {
"recorded-date": "11-08-2022, 13:22:01",
"recorded-date": "11-03-2025, 19:12:57",
"recorded-content": {
"exception": "An error occurred (ValidationError) when calling the DescribeChangeSet operation: Stack [somestack] does not exist"
}
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_delete_change_set_exception": {
"recorded-date": "11-08-2022, 14:07:38",
"recorded-date": "11-03-2025, 19:13:48",
"recorded-content": {
"e1": "<ExceptionInfo ClientError('An error occurred (ValidationError) when calling the DeleteChangeSet operation: Stack [nostack] does not exist') tblen=3>",
"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>"
"e1": {
"Error": {
"Code": "ValidationError",
"Message": "Stack [nostack] does not exist",
"Type": "Sender"
},
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 400
}
},
"e2": {
"Error": {
"Code": "ValidationError",
"Message": "StackName must be specified if ChangeSetName is not specified as an ARN.",
"Type": "Sender"
},
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 400
}
}
}
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_name_conflicts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"last_validated_date": "2023-11-22T07:49:15+00:00"
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_delete_change_set_exception": {
"last_validated_date": "2022-08-11T12:07:38+00:00"
"last_validated_date": "2025-03-11T19:13:48+00:00"
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_deleted_changeset": {
"last_validated_date": "2022-08-11T09:11:47+00:00"
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_describe_change_set_nonexisting": {
"last_validated_date": "2022-08-11T11:22:01+00:00"
"last_validated_date": "2025-03-11T19:12:57+00:00"
},
"tests/aws/services/cloudformation/api/test_changesets.py::test_describe_change_set_with_similarly_named_stacks": {
"last_validated_date": "2024-03-06T13:56:47+00:00"
Expand Down
57 changes: 29 additions & 28 deletions tests/aws/services/events/test_archive_and_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime, timedelta, timezone

import pytest
from botocore.exceptions import ClientError

from localstack.testing.pytest import markers
from localstack.utils.strings import short_uid
Expand Down Expand Up @@ -272,7 +273,7 @@ def test_create_archive_error_duplicate(
EventPattern=json.dumps(TEST_EVENT_PATTERN),
RetentionDays=1,
)
with pytest.raises(Exception) as error:
with pytest.raises(ClientError) as error:
aws_client.events.create_archive(
ArchiveName=archive_name,
EventSourceArn=event_bus_arn,
Expand All @@ -282,7 +283,7 @@ def test_create_archive_error_duplicate(
)

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

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

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

snapshot.add_transformer(
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
)
snapshot.match("describe-archive-unknown-archive-error", error)
snapshot.match("describe-archive-unknown-archive-error", error.value.response)

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

snapshot.add_transformer(
[snapshot.transform.regex(not_existing_event_bus_name, "<event-bus-name>")]
)
snapshot.match("list-archives-unknown-event-bus-error", error)
snapshot.match("list-archives-unknown-event-bus-error", error.value.response)

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

snapshot.add_transformer(
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
)
snapshot.match("update-archive-unknown-archive-error", error)
snapshot.match("update-archive-unknown-archive-error", error.value.response)

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

snapshot.add_transformer(
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
)
snapshot.match("delete-archive-unknown-archive-error", error)
snapshot.match("delete-archive-unknown-archive-error", error.value.response)


class TestReplay:
Expand Down Expand Up @@ -669,7 +670,7 @@ def test_start_replay_error_unknown_event_bus(
end_time = datetime.now(timezone.utc)

replay_name = f"test-replay-{short_uid()}"
with pytest.raises(Exception) as error:
with pytest.raises(ClientError) as error:
aws_client.events.start_replay(
ReplayName=replay_name,
Description="description of the replay",
Expand All @@ -684,11 +685,11 @@ def test_start_replay_error_unknown_event_bus(
snapshot.add_transformer(
[snapshot.transform.regex(not_existing_event_bus_name, "<event-bus-name>")]
)
snapshot.match("start-replay-unknown-event-bus-error", error)
snapshot.match("start-replay-unknown-event-bus-error", error.value.response)

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

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

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

@markers.aws.validated
def test_start_replay_error_unknown_archive(
Expand All @@ -709,7 +710,7 @@ def test_start_replay_error_unknown_archive(
not_existing_archive_name = f"doesnotexist-{short_uid()}"
start_time = datetime.now(timezone.utc) - timedelta(minutes=1)
end_time = datetime.now(timezone.utc)
with pytest.raises(Exception) as error:
with pytest.raises(ClientError) as error:
aws_client.events.start_replay(
ReplayName="test-replay",
Description="description of the replay",
Expand All @@ -724,7 +725,7 @@ def test_start_replay_error_unknown_archive(
snapshot.add_transformer(
[snapshot.transform.regex(not_existing_archive_name, "<archive-name>")]
)
snapshot.match("start-replay-unknown-archive-error", error)
snapshot.match("start-replay-unknown-archive-error", error.value.response)

@markers.aws.validated
def test_start_replay_error_duplicate_name_same_archive(
Expand All @@ -751,7 +752,7 @@ def test_start_replay_error_duplicate_name_same_archive(
},
)

with pytest.raises(Exception) as error:
with pytest.raises(ClientError) as error:
aws_client.events.start_replay(
ReplayName=replay_name,
Description="description of the replay",
Expand All @@ -764,7 +765,7 @@ def test_start_replay_error_duplicate_name_same_archive(
)

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

@markers.aws.validated
def test_start_replay_error_duplicate_different_archive(
Expand Down Expand Up @@ -800,7 +801,7 @@ def test_start_replay_error_duplicate_different_archive(
},
)

with pytest.raises(Exception) as error:
with pytest.raises(ClientError) as error:
aws_client.events.start_replay(
ReplayName=replay_name,
Description="description of the replay",
Expand All @@ -813,7 +814,7 @@ def test_start_replay_error_duplicate_different_archive(
)

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

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

replay_name = f"test-replay-{short_uid()}"
with pytest.raises(Exception) as error:
with pytest.raises(ClientError) as error:
aws_client.events.start_replay(
ReplayName=replay_name,
Description="description of the replay",
Expand All @@ -845,7 +846,7 @@ def test_start_replay_error_invalid_end_time(
},
)

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

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

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

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

snapshot.add_transformer(
[snapshot.transform.regex(not_existing_replay_name, "<replay-name>")]
)
snapshot.match("describe-replay-unknown-replay-error", error)
snapshot.match("describe-replay-unknown-replay-error", error.value.response)
Loading
Loading