Skip to content

Commit

Permalink
fix: Hadlokas Haneiros for second day Yom Tov
Browse files Browse the repository at this point in the history
  • Loading branch information
essel-dev committed Jul 28, 2024
1 parent ff8c46a commit a86b672
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/jewcal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
from datetime import date, timedelta
from warnings import warn

from .constants import Action
from .models.events import Events
from .models.jewish_date import JewishDate
from .models.zmanim import Location, Zmanim
Expand Down Expand Up @@ -150,7 +151,7 @@ def __init__(
weekday: int = weekday_from_absdate(absdate)
self._events = Events(weekday, month, day, diaspora)

if self._zmanim is not None and not self._events._is_erev():
if self._zmanim is not None and self._events.action != Action.CANDLES.value:
self._zmanim.hadlokas_haneiros = None

@property
Expand Down
44 changes: 37 additions & 7 deletions tests/jewcal/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,12 @@ def test_is_now_after_nightfall_false(
jewcal = JewCal(date_, location)
self.assertEqual(jewcal.jewish_date.gregorian_date, date_)

@patch('src.jewcal.core.date_today', autospec=True)
def test_hadlokas_haneiros_is_set(self, mock_today: Mock) -> None:
def test_hadlokas_haneiros_is_set(self) -> None:
"""Test Hadlokas Haneiros is set."""
lat, lon = 51.22047, 4.40026 # Antwerpen
location = Location(latitude=lat, longitude=lon)

date_ = date(2024, 5, 31) # erev shabbos
mock_today.return_value = date_
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
Expand Down Expand Up @@ -245,21 +243,53 @@ def test_hadlokas_haneiros_is_set_and_after_nightfall(

self.assertIsNotNone(jewcal.zmanim.hadlokas_haneiros)

@patch('src.jewcal.core.date_today', autospec=True)
def test_hadlokas_haneiros_is_not_set(self, mock_today: Mock) -> None:
def test_hadlokas_haneiros_is_set_second_day_yom_tov(self) -> None:
"""Test has Hadlokas Haneiros for second day of Yom Tov."""
lat, lon = 51.22047, 4.40026 # Antwerpen
location = Location(latitude=lat, longitude=lon)

date_ = date(2024, 6, 11) # Erev Shavuos
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
self.assertIsNotNone(jewcal.zmanim.hadlokas_haneiros)

date_ = date(2024, 6, 12) # Shavuos 1
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
self.assertIsNotNone(jewcal.zmanim.hadlokas_haneiros)

date_ = date(2024, 6, 13) # Shavuos 2
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
self.assertIsNone(jewcal.zmanim.hadlokas_haneiros)

date_ = date(2024, 6, 14) # Erev Shabbos
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
self.assertIsNotNone(jewcal.zmanim.hadlokas_haneiros)

date_ = date(2024, 6, 15) # Shabbos
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
self.assertIsNone(jewcal.zmanim.hadlokas_haneiros)

def test_hadlokas_haneiros_is_not_set(self) -> None:
"""Test Hadlokas Haneiros is not set."""
lat, lon = 51.22047, 4.40026 # Antwerpen
location = Location(latitude=lat, longitude=lon)

date_ = date(2024, 6, 1) # shabbos
mock_today.return_value = date_
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
self.assertIsNone(jewcal.zmanim.hadlokas_haneiros)

date_ = date(2024, 6, 2) # sunday
mock_today.return_value = date_
jewcal = JewCal(date_, location)
if not jewcal.zmanim:
raise TypeError
Expand Down

0 comments on commit a86b672

Please sign in to comment.