def test_purim(self): purims = [dates.HebrewDate(5778, 12, 14), dates.HebrewDate(5779, 13, 14)] for purim in purims: assert holiday(purim) == 'Purim' assert holiday(purim + 1) == 'Shushan Purim' assert holiday(dates.HebrewDate(5779, 12, 14)) == 'Purim Katan'
def test_pesach(self): pesach = dates.HebrewDate(5778, 1, 15) for i in range(6): assert (holiday(pesach + i, True) == 'Pesach' and holiday(pesach + i) == 'Pesach') eighth = pesach + 7 assert holiday(eighth) == 'Pesach' and holiday(eighth, True) is None assert holiday(eighth + 1) is None
def test_purim(self): purims = [ dates.HebrewDate(5778, 12, 14), dates.HebrewDate(5779, 13, 14) ] for purim in purims: assert holiday(purim) == 'Purim' assert holiday(purim + 1) == 'Shushan Purim' assert holiday(dates.HebrewDate(5779, 12, 14)) == 'Purim Katan'
def test_pesach(self): pesach = dates.HebrewDate(5778, 1, 15) for i in range (6): assert ( holiday(pesach + i, True) == 'Pesach' and holiday(pesach + i) == 'Pesach' ) eighth = pesach + 7 assert holiday(eighth) == 'Pesach' and holiday(eighth, True) is None assert holiday(eighth + 1) is None
def test_roshhashana(self): roshhashana = dates.HebrewDate(5779, 7, 1) assert all([ holiday(day, location) == 'Rosh Hashana' for day in [roshhashana, roshhashana + 1] for location in [True, False] ])
def test_esther(self): fasts = [ dates.HebrewDate(5778, 12, 13), dates.HebrewDate(5776, 13, 13), dates.HebrewDate(5777, 12, 11), #nidche dates.HebrewDate(5784, 13, 11) #ibbur and nidche ] for fast in fasts: assert holiday(fast) == 'Taanis Esther' non_fasts = [ dates.HebrewDate(5776, 12, 13), dates.HebrewDate(5777, 12, 13), dates.HebrewDate(5784, 12, 11), dates.HebrewDate(5784, 13, 13) ] for non in non_fasts: assert holiday(non) is None
def get_holiday(date=dates.HebrewDate.today()): """ If not fast today, check if tomorrow is a holiday :param date: the date to check. typeof `dates.HebrewDate` from `pyluach` :return: tuple (name => string, is_holiday => bool) or None if no holiday """ fast_table = hebrewcal._fast_day_table(date.year) if date in fast_table: return fast_table[date], False holiday = hebrewcal.holiday(date + 1, israel=True) if holiday: return holiday, True return None, None
def test_chanuka(self): for year in [5778, 5787]: chanuka = dates.HebrewDate(year, 9, 25) for i in range(8): assert holiday(chanuka + i) == 'Chanuka' assert holiday(chanuka + 8) is None
def test_shmini(self): shmini = dates.HebrewDate(5780, 7, 22) assert holiday(shmini, True) == 'Shmini Atzeres' assert holiday(shmini) == 'Shmini Atzeres' assert holiday(shmini + 1) == 'Simchas Torah' assert holiday(shmini + 1, True) is None
def test_lagbaomer(self): assert holiday(dates.GregorianDate(2018, 5, 3)) == "Lag Ba'omer"
def test_asara(self): assert holiday(dates.GregorianDate(2018, 12, 18)) == '10 of Teves'
def test_tubeav(self): assert holiday(dates.HebrewDate(5779, 5, 15)) == "Tu B'av"
def test_av(self): fasts = [dates.HebrewDate(5777, 5, 9), dates.HebrewDate(5778, 5, 10)] for fast in fasts: assert holiday(fast) == '9 of Av' assert holiday(dates.HebrewDate(5778, 5, 9)) is None
def test_tamuz(self): fasts = [dates.HebrewDate(5777, 4, 17), dates.HebrewDate(5778, 4, 18)] for fast in fasts: assert holiday(fast) == '17 of Tamuz' assert holiday(dates.HebrewDate(5778, 4, 17)) is None
def test_gedalia(self): assert holiday(dates.HebrewDate(5779, 7, 3)) == 'Tzom Gedalia' assert holiday(dates.HebrewDate(5778, 7, 3)) is None assert holiday(dates.HebrewDate(5778, 7, 4)) == 'Tzom Gedalia'
def test_shavuos(self): shavuos = dates.HebrewDate(5778, 3, 6) assert all([holiday(day) == 'Shavuos' for day in [shavuos, shavuos + 1]]) assert holiday(shavuos, True) == 'Shavuos' assert holiday(shavuos + 1, True) is None
def test_tubshvat(self): assert holiday(dates.HebrewDate(5779, 11, 15)) == "Tu B'shvat"
def test_chanuka(self): chanuka = dates.HebrewDate(5778, 9, 25) for i in range(8): assert holiday(chanuka + i) == 'Chanuka'
def test_roshhashana(self): roshhashana = dates.HebrewDate(5779, 7, 1) assert all([holiday(day, location) == 'Rosh Hashana' for day in[roshhashana, roshhashana + 1] for location in [True, False] ])
def test_pesach_sheni(self): ps = dates.HebrewDate(5781, 2, 14) assert holiday(ps) == 'Pesach Sheni' assert holiday(ps + 1) is None
def test_shavuos(self): shavuos = dates.HebrewDate(5778, 3, 6) assert all( [holiday(day) == 'Shavuos' for day in [shavuos, shavuos + 1]]) assert holiday(shavuos, True) == 'Shavuos' assert holiday(shavuos + 1, True) is None
def test_succos(self): day = dates.HebrewDate(5778, 7, 18) assert holiday(day) == 'Succos' day2 = dates.HebrewDate(5778, 7, 23) assert holiday(day2, israel=True) is None
def test_yomkippur(self): assert holiday(dates.HebrewDate(5775, 7, 10)) == 'Yom Kippur'