mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 19:33:12 +00:00
Some checks are pending
Deploy / Deploy to prod (push) Waiting to run
* fix(cutover): write Slack secrets into empty Terraform shells DescribeSecret succeeds on HCP-created shells with no version, so skip-if-exists left roster and Slack tokens unset. * feat(infra): migrate afterhours to HCP Terraform (PLAT-74) Replace the mgmt SAM stack with a prod-only HCP workspace, in-repo hcptf IAM, stub Lambdas, and zip CD on push to main. * fix(cutover): retry DDB unprocessed items and skip past at() holidays Unprocessed BatchWriteItem rows and leftover past at() schedules would drop roster data or abort holiday recreation during prod cutover.
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
"""recreate_holiday_schedules skips past at() expressions, not only EndDate."""
|
|
|
|
from datetime import datetime, timezone
|
|
from zoneinfo import ZoneInfo
|
|
import importlib.util
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def _load():
|
|
spec = importlib.util.spec_from_file_location(
|
|
"recreate_holiday_schedules",
|
|
ROOT / "scripts" / "cutover" / "recreate_holiday_schedules.py",
|
|
)
|
|
mod = importlib.util.module_from_spec(spec)
|
|
sys.modules["recreate_holiday_schedules"] = mod
|
|
spec.loader.exec_module(mod)
|
|
return mod
|
|
|
|
|
|
mod = _load()
|
|
|
|
|
|
def test_schedule_when_parses_at_expression_in_eastern():
|
|
detail = {
|
|
"ScheduleExpression": "at(2026-07-04T08:00:00)",
|
|
"ScheduleExpressionTimezone": "America/New_York",
|
|
}
|
|
when = mod.schedule_when(detail)
|
|
expected = datetime(2026, 7, 4, 8, 0, 0, tzinfo=ZoneInfo("America/New_York")).astimezone(
|
|
timezone.utc
|
|
)
|
|
assert when == expected
|
|
|
|
|
|
def test_past_at_expression_is_before_now_without_end_date():
|
|
detail = {
|
|
"ScheduleExpression": "at(2020-01-01T08:00:00)",
|
|
"ScheduleExpressionTimezone": "America/New_York",
|
|
}
|
|
when = mod.schedule_when(detail)
|
|
assert when is not None
|
|
assert when < datetime.now(timezone.utc)
|
|
assert "EndDate" not in detail
|
|
assert "StartDate" not in detail
|
|
|
|
|
|
def test_future_at_expression_is_kept():
|
|
detail = {
|
|
"ScheduleExpression": "at(2099-12-25T17:00:00)",
|
|
"ScheduleExpressionTimezone": "America/New_York",
|
|
}
|
|
when = mod.schedule_when(detail)
|
|
assert when is not None
|
|
assert when > datetime.now(timezone.utc)
|