infrastructure/tests/release-schedule.py

33 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""D-098 cadence: anchored three-day OSTree grid and calendar-day-30 ISO."""
import importlib.util
from datetime import date, datetime, timezone
from pathlib import Path
spec = importlib.util.spec_from_file_location('schedule', Path(__file__).parents[1] / 'pipeline/release-schedule.py')
s = importlib.util.module_from_spec(spec)
spec.loader.exec_module(s)
assert s.mode(date(2026, 11, 9)) == 'ostree'
for day in (12, 15, 18, 21, 24, 27):
assert s.mode(date(2026, 11, day)) == 'ostree', day
assert s.mode(date(2026, 11, 30)) == 'iso'
assert s.mode(date(2026, 11, 10)) is None and s.mode(date(2026, 11, 29)) is None
# The grid is an interval, not a day-of-month rule: it continues across the
# month and year boundary and never substitutes a missing calendar day.
for day in (date(2026, 12, 3), date(2026, 12, 6), date(2027, 1, 2)):
assert s.mode(day) == 'ostree', day
assert s.mode(date(2026, 12, 30)) == 'iso'
assert s.mode(date(2027, 2, 28)) == 'ostree'
assert s.mode(date(2026, 11, 8)) is None
assert s.next_release(datetime(2026, 11, 9, 12, tzinfo=timezone.utc)) == {
'date': '2026-11-12', 'mode': 'ostree', 'time': '00:00 UTC'}
assert s.next_release(datetime(2026, 11, 29, 23, tzinfo=timezone.utc))['mode'] == 'iso'
assert s.next_release(datetime(2026, 11, 30, 1, tzinfo=timezone.utc))['date'] == '2026-12-03'
assert s.next_release(datetime(2027, 2, 27, tzinfo=timezone.utc))['date'] == '2027-02-28'
for start in (datetime(2026, 11, 9, tzinfo=timezone.utc), datetime(2027, 3, 29, tzinfo=timezone.utc)):
nxt = s.next_release(start)
day = date.fromisoformat(nxt['date'])
assert day > start.date() and s.mode(day) == nxt['mode']
print('RELEASE_SCHEDULE_PASS')