afterhours-shift-manager/tests/scripts/test_retarget_holiday_schedules_to_sqs.py

53 lines
1.6 KiB
Python
Raw Normal View History

"""retarget_holiday_schedules_to_sqs builds the SQS holiday payload."""
import importlib.util
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def _load():
spec = importlib.util.spec_from_file_location(
"retarget_holiday_schedules_to_sqs",
ROOT / "scripts" / "cutover" / "retarget_holiday_schedules_to_sqs.py",
)
mod = importlib.util.module_from_spec(spec)
sys.modules["retarget_holiday_schedules_to_sqs"] = mod
spec.loader.exec_module(mod)
return mod
mod = _load()
def test_action_and_date_from_lambda_input():
action, date = mod.action_and_date(
"holiday-activate-20260704",
'{"action":"activate","date":"2026-07-04"}',
)
assert action == "activate"
assert date == "2026-07-04"
def test_action_and_date_from_schedule_name_when_input_empty():
action, date = mod.action_and_date("holiday-deactivate-20260704", "")
assert action == "deactivate"
assert date == "2026-07-04"
def test_holiday_sqs_input_shape():
payload = mod.holiday_sqs_input("activate", "2026-07-04")
assert payload == '{"event": "holiday", "action": "activate", "date": "2026-07-04"}'
def test_holiday_scheduler_role_arn_follows_caller_account():
assert mod.holiday_scheduler_role_arn(mod.PROD_ACCOUNT) == (
"arn:aws:iam::011934824531:role/tf-managed/"
"afterhours-shift-manager-holiday-scheduler"
)
assert mod.holiday_scheduler_role_arn(mod.DEV_ACCOUNT) == (
"arn:aws:iam::710827005802:role/tf-managed/"
"afterhours-shift-manager-holiday-scheduler"
)