示例#1
0
 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'
示例#2
0
 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
示例#3
0
 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'
示例#4
0
 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
示例#5
0
 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]
     ])
示例#6
0
 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
示例#7
0
 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
示例#8
0
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
示例#9
0
 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
示例#10
0
 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
示例#11
0
 def test_lagbaomer(self):
     assert holiday(dates.GregorianDate(2018, 5, 3)) == "Lag Ba'omer"
示例#12
0
 def test_asara(self):
     assert holiday(dates.GregorianDate(2018, 12, 18)) == '10 of Teves'
示例#13
0
 def test_tubeav(self):
     assert holiday(dates.HebrewDate(5779, 5, 15)) == "Tu B'av"
示例#14
0
 def test_lagbaomer(self):
     assert holiday(dates.GregorianDate(2018, 5, 3)) == "Lag Ba'omer"
示例#15
0
 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
示例#16
0
 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
示例#17
0
 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
示例#18
0
 def test_asara(self):
     assert holiday(dates.GregorianDate(2018, 12, 18)) == '10 of Teves'
示例#19
0
 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'
示例#20
0
 def test_tubeav(self):
     assert holiday(dates.HebrewDate(5779, 5, 15)) == "Tu B'av"
示例#21
0
 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
示例#22
0
 def test_tubshvat(self):
     assert holiday(dates.HebrewDate(5779, 11, 15)) == "Tu B'shvat"
示例#23
0
 def test_chanuka(self):
     chanuka = dates.HebrewDate(5778, 9, 25)
     for i in range(8):
         assert holiday(chanuka + i) == 'Chanuka'
示例#24
0
 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]
                ])
示例#25
0
 def test_pesach_sheni(self):
     ps = dates.HebrewDate(5781, 2, 14)
     assert holiday(ps) == 'Pesach Sheni'
     assert holiday(ps + 1) is None
示例#26
0
 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
示例#27
0
 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
示例#28
0
 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
示例#29
0
 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'
示例#30
0
 def test_yomkippur(self):
     assert holiday(dates.HebrewDate(5775, 7, 10)) == 'Yom Kippur'
示例#31
0
 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
示例#32
0
 def test_tubshvat(self):
     assert holiday(dates.HebrewDate(5779, 11, 15)) == "Tu B'shvat"
示例#33
0
 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
示例#34
0
 def test_yomkippur(self):
     assert holiday(dates.HebrewDate(5775, 7, 10)) == 'Yom Kippur'