mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 07:53:11 +00:00
* feat(api): collapse Slack, portal, and jobs onto Fargate (PLAT-216) Move HTTP and scheduled work onto one always-on Flask task so after-hours loses Lambda cold start without changing the Cognito or roster contracts. * fix(portal-api): keep CORS headers on unexpected 500s Portal SPA error handling needs Access-Control-Allow-Origin even when DynamoDB or other internals fail, otherwise the browser hides the 500. * fix(api): retarget holidays per account and ship App Home changelog (PLAT-216) * fix(iam): list ECS tasks and fail closed on non-prod Paychex (PLAT-216) * fix(portal-api): serve portal JSON with an explicit JSON content type
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""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"
|
|
)
|