mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 10:13:11 +00:00
* ci(workflows): call org reusable CI and Fargate CD Local CI and the image deploy duplicated the org workflows and still required ci / ci. Pin the callers to those workflows and trust the reusable deploy ref. * test(ci): probe ruff with an undefined name * test(ci): remove the undefined-name ruff probe * ci: retrigger checks after removing the ruff probe * test(ci): probe ruff with an unused import * style: apply formatter * test(ci): remove the autofix probe --------- Co-authored-by: sea-haven-auto-fix[bot] <332630863+sea-haven-auto-fix[bot]@users.noreply.github.com>
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)
|