Files
troupe-standup/wizard-work/beam/test_zeller_dow.py
T

43 lines
1.8 KiB
Python

import unittest
from zeller_dow import dow
class TestZellerDow(unittest.TestCase):
def test_gap_dates_raise(self):
for day in range(5, 15):
with self.assertRaises(ValueError):
dow(1582, 10, day)
def test_silent_month_length_aliases_raise(self):
cases = [(2026, 2, 31), (2026, 2, 30), (2026, 4, 31),
(1900, 2, 29), (2000, 2, 30), (2024, 13, 1),
(2024, 0, 1), (2024, 1, 0), (2024, 1, 32)]
for y, m, d in cases:
with self.assertRaises(ValueError):
dow(y, m, d)
def test_valid_anchors(self):
# 1582-10-15 was a Friday (Gregorian cutover)
self.assertEqual(dow(1582, 10, 15), "Friday")
# 1582-10-04 Julian Thursday
self.assertEqual(dow(1582, 10, 4), "Thursday")
self.assertEqual(dow(2024, 2, 29), "Thursday") # leap day exists
self.assertEqual(dow(2026, 10, 27), "Tuesday")
def test_leap_day_invalid_non_leap(self):
with self.assertRaises(ValueError):
dow(2023, 2, 29)
def test_julian_leap_branch_is_the_witness(self):
# Q85 M-JUL: with the calendar branch dropped -- `leap = _gregorian_leap(y)`
# unconditionally -- every other cell here still passes and this date
# alone moves from "Saturday" to ValueError. 1500 is a Julian leap year
# and not a Gregorian one, so it is the only year in the suite that
# separates the two branches. Cross-checked two ways outside the module:
# its JDN is shared by Gregorian 1500-03-10, whose datetime weekday is
# Saturday, and a walk from Julian 1582-10-04 (a Thursday) lands on
# Saturday too. Both readings are in the Q85 record.
self.assertEqual(dow(1500, 2, 29), "Saturday")
if __name__ == "__main__":
unittest.main()