def test_year_zero(self): assert gregorian.to_jd(1, 1, 1) == 1.0 + gregorian.to_jd(0, 12, 31) assert julian.to_jd(1, 1, 1) == 1.0 + julian.to_jd(0, 12, 31) assert julian.from_jd(julian.to_jd(1, 1, 1) - 1) == (0, 12, 31) self.assertEqual(gregorian.from_jd(gregorian.to_jd(1, 1, 1) - 1), (0, 12, 31))
def test_julian_legal_date(self): try: julian.to_jd(1900, 2, 29) except ValueError: self.fail('Unexpected ValueError: "julian.to_jd(1900, 2, 29)"') self.assertRaises(ValueError, julian.to_jd, 2014, 2, 29) self.assertRaises(ValueError, julian.to_jd, 2014, 3, 32) self.assertRaises(ValueError, julian.to_jd, 2014, 4, 31) self.assertRaises(ValueError, julian.to_jd, 2014, 5, -1)
def test_gregorian_julian_dif_proleptic(self): self.assertEqual(julian.to_jd(1500, 5, 10), gregorian.to_jd(1500, 5, 20)) assert julian.to_jd(1300, 5, 10) == gregorian.to_jd(1300, 5, 18) assert julian.to_jd(1000, 5, 10) == gregorian.to_jd(1000, 5, 16) assert julian.to_jd(900, 5, 10) == gregorian.to_jd(900, 5, 15) assert julian.to_jd(300, 5, 10) == gregorian.to_jd(300, 5, 11) assert julian.to_jd(200, 5, 10) == gregorian.to_jd(200, 5, 10) assert julian.to_jd(100, 5, 10) == gregorian.to_jd(100, 5, 9) assert julian.to_jd(-1, 5, 10) == gregorian.to_jd(-1, 5, 8)
def test_from_julian(self): self.assertEqual(self.jd, julian.to_jd(*julian.from_jd(self.jd))) self.assertEqual(julian.from_jd(self.c), (1492, 10, 12)) self.assertEqual(julian.from_jd(2400000.5), (1858, 11, 5)) self.assertEqual(julian.from_jd(2399830.5), (1858, 5, 19))
def test_to_julian(self): self.assertEqual(julian.to_jd(1858, 11, 5), 2400000.5) self.assertEqual(julian.to_jd(1492, 10, 12), self.c)