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
29 changes: 29 additions & 0 deletions tests/aws/services/scheduler/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging

import pytest

from localstack.utils.strings import short_uid

LOG = logging.getLogger(__name__)


@pytest.fixture
def events_scheduler_create_schedule_group(aws_client):
schedule_group_arns = []

def _events_scheduler_create_schedule_group(name, **kwargs):
if not name:
name = f"events-test-schedule-groupe-{short_uid()}"
response = aws_client.scheduler.create_schedule_group(Name=name, **kwargs)
schedule_group_arn = response["ScheduleGroupArn"]
schedule_group_arns.append(schedule_group_arn)

return schedule_group_arn

yield _events_scheduler_create_schedule_group

for schedule_group_arn in schedule_group_arns:
try:
aws_client.scheduler.delete_schedule_group(ScheduleGroupArn=schedule_group_arn)
except Exception:
LOG.info("Failed to delete schedule group %s", schedule_group_arn)
46 changes: 46 additions & 0 deletions tests/aws/services/scheduler/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from localstack.testing.aws.util import in_default_partition
from localstack.testing.pytest import markers
from localstack.utils.common import short_uid


@pytest.mark.skipif(
Expand All @@ -12,3 +13,48 @@ def test_list_schedules(aws_client):
# simple smoke test to assert that the provider is available, without creating any schedules
result = aws_client.scheduler.list_schedules()
assert isinstance(result.get("Schedules"), list)


@markers.aws.validated
def test_tag_resource(aws_client, events_scheduler_create_schedule_group, snapshot):
name = short_uid()
schedule_group_arn = events_scheduler_create_schedule_group(name)

response = aws_client.scheduler.tag_resource(
ResourceArn=schedule_group_arn,
Tags=[
{
"Key": "TagKey",
"Value": "TagValue",
}
],
)

response = aws_client.scheduler.list_tags_for_resource(ResourceArn=schedule_group_arn)

assert response["Tags"][0]["Key"] == "TagKey"
assert response["Tags"][0]["Value"] == "TagValue"

snapshot.match("list-tagged-schedule", response)


@markers.aws.validated
def test_untag_resource(aws_client, events_scheduler_create_schedule_group, snapshot):
name = short_uid()
tags = [
{
"Key": "TagKey",
"Value": "TagValue",
}
]
schedule_group_arn = events_scheduler_create_schedule_group(name, Tags=tags)

response = aws_client.scheduler.untag_resource(
ResourceArn=schedule_group_arn, TagKeys=["TagKey"]
)

response = aws_client.scheduler.list_tags_for_resource(ResourceArn=schedule_group_arn)

assert response["Tags"] == []

snapshot.match("list-untagged-schedule", response)
31 changes: 31 additions & 0 deletions tests/aws/services/scheduler/test_scheduler.snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"tests/aws/services/scheduler/test_scheduler.py::test_tag_resource": {
"recorded-date": "04-12-2024, 10:07:28",
"recorded-content": {
"list-tagged-schedule": {
"Tags": [
{
"Key": "TagKey",
"Value": "TagValue"
}
],
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
},
"tests/aws/services/scheduler/test_scheduler.py::test_untag_resource": {
"recorded-date": "04-12-2024, 10:08:11",
"recorded-content": {
"list-untagged-schedule": {
"Tags": [],
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
}
}
6 changes: 6 additions & 0 deletions tests/aws/services/scheduler/test_scheduler.validation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"tests/aws/services/scheduler/test_scheduler.py::test_list_schedules": {
"last_validated_date": "2024-06-11T22:50:50+00:00"
},
"tests/aws/services/scheduler/test_scheduler.py::test_tag_resource": {
"last_validated_date": "2024-12-04T10:07:28+00:00"
},
"tests/aws/services/scheduler/test_scheduler.py::test_untag_resource": {
"last_validated_date": "2024-12-04T10:08:11+00:00"
}
}
Loading