def test_bahai(self): self.reflexive(bahai.from_jd, bahai.to_jd) self.assertEqual(bahai.from_gregorian(1844, 3, 21), (1, 1, 1)) self.assertEqual(bahai.to_gregorian(1, 1, 1), (1844, 3, 21)) self.assertEqual(bahai.month_length(1, 3), 19) self.assertEqual(bahai.month_length(1, 1), 19) self.assertEqual(bahai.month_length(4, 19), 5) self.assertEqual(bahai.month_length(5, 19), 4) self.assertEqual(self.jd, bahai.to_jd(*bahai.from_jd(self.jd)))
def test_month_length_ha(self): official = { 4: [ 2016, 2017, 2019, 2020, 2021, 2023, 2024, 2025, 2027, 2028, 2029, 2030, 2032, 2033, 2034, 2036, 2037, 2038, 2040, 2041, 2042, 2044, 2045, 2046, 2048, 2049, 2050, 2052, 2053, 2054, 2056, 2057, 2058, 2059, 2061, 2062, 2063, 2065, ], 5: [ 2018, 2022, 2026, 2031, 2035, 2039, 2043, 2047, 2051, 2055, 2060, 2064 ], } for length, gyears in official.items(): for gyear in gyears: byear = gyear - 1844 self.assertEqual(length, bahai.month_length(byear, 19))
def test_month_length(self): for x in range(1, 19): self.assertEqual(bahai.month_length(2019, x), 19)
def test_days_ha(self): days_official = { 2016: 4, 2017: 4, 2018: 5, 2019: 4, 2020: 4, 2021: 4, 2022: 5, 2023: 4, 2024: 4, 2025: 4, 2026: 5, 2027: 4, 2028: 4, 2029: 4, 2030: 4, 2031: 5, 2032: 4, 2033: 4, 2034: 4, 2035: 5, 2036: 4, 2037: 4, 2038: 4, 2039: 5, 2040: 4, 2041: 4, 2042: 4, 2043: 5, 2044: 4, 2045: 4, 2046: 4, 2047: 5, 2048: 4, 2049: 4, 2050: 4, 2051: 5, 2052: 4, 2053: 4, 2054: 4, 2055: 5, 2056: 4, 2057: 4, 2058: 4, 2059: 4, 2060: 5, 2061: 4, 2062: 4, 2063: 4, 2064: 5, 2065: 4 } for year in days_official: bahaiyear = year - 1844 # there's some off-by-one business here # the Baha'i year of Ayam-i-Ha in 20XX # starts in 20XX-1 actual = (year, bahai.month_length(bahaiyear, 19)) expected = (year, days_official[year]) self.assertEqual (expected, actual)
def test_bahai(self): self.reflexive(bahai.from_jd, bahai.to_jd) self.assertEqual(bahai.month_length(1, 3), 19) self.assertEqual(bahai.month_length(1, 1), 19) self.assertEqual(self.jd, bahai.to_jd(*bahai.from_jd(self.jd)))
def test_monthlength(self): self.assertEqual(bahai.month_length(1, 3), 19) self.assertEqual(bahai.month_length(1, 1), 19)