infrastructure/tests/release-schedule.py

29 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""D-108 cadence: one monthly ISO+OSTree cycle on the 1st at 00:00 UTC."""
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, 1)) == 'iso'
assert s.mode(date(2026, 12, 1)) == 'iso'
assert s.mode(date(2027, 1, 1)) == 'iso'
# Calendar dates, not an interval: every other day is unscheduled.
for day in (date(2026, 11, 2), date(2026, 11, 15), date(2026, 11, 30)):
assert s.mode(day) is None, day
# February has no 30th; the rule must not substitute another date.
assert s.mode(date(2027, 2, 28)) is None and s.mode(date(2027, 3, 1)) == 'iso'
assert s.next_release(datetime(2026, 11, 15, 12, tzinfo=timezone.utc)) == {
'date': '2026-12-01', 'mode': 'iso', 'time': '00:00 UTC'}
assert s.next_release(datetime(2026, 11, 30, 23, tzinfo=timezone.utc))['date'] == '2026-12-01'
assert s.next_release(datetime(2026, 12, 1, 0, 1, tzinfo=timezone.utc))['date'] == '2027-01-01'
assert s.next_release(datetime(2027, 2, 1, tzinfo=timezone.utc))['date'] == '2027-03-01'
for start in (datetime(2026, 11, 15, tzinfo=timezone.utc), datetime(2027, 1, 31, tzinfo=timezone.utc)):
nxt = s.next_release(start)
day = date.fromisoformat(nxt['date'])
assert day > start.date() and day.day == 1 and s.mode(day) == nxt['mode']
print('RELEASE_SCHEDULE_PASS')