diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 19c2ef5..515c9db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,10 @@ # Local Development ## Install +### Project code +```sh +cd && git clone # path-to-this-repository.git +``` + ### Python Verify if Python is installed. ```sh @@ -13,11 +18,6 @@ To activate: pyenv local 3.10 3.11 3.12 ``` -### Project code -```sh -cd && git clone # path-to-this-repository.git -``` - ### Virtual environment ```sh cd # path-to-downloaded-repository diff --git a/pyproject.toml b/pyproject.toml index 12bddeb..1acf5b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ dynamic = ['version'] keywords = [ 'jewish calendar', 'hebrew calendar', + 'zmanim', ] license = {file = 'LICENSE'} name = 'jewcal' diff --git a/src/jewcal/core.py b/src/jewcal/core.py index 67e50dd..6cd3b88 100644 --- a/src/jewcal/core.py +++ b/src/jewcal/core.py @@ -140,7 +140,7 @@ def __init__( use_tzeis_hakochavim=location.use_tzeis_hakochavim, ): gregorian += timedelta(days=1) - self._zmanim = Zmanim(gregorian, location) + self._zmanim = Zmanim(gregorian, location, set_hadlokas_haneiros=True) absdate = gregorian_to_absdate(gregorian.year, gregorian.month, gregorian.day) year, month, day = absdate_to_jewish(absdate) diff --git a/src/jewcal/models/events.py b/src/jewcal/models/events.py index 79cb0a1..735cf70 100644 --- a/src/jewcal/models/events.py +++ b/src/jewcal/models/events.py @@ -99,7 +99,6 @@ def _is_erev_yomtov(self) -> bool: self.yomtov and 'Pesach 6' in self.yomtov, ], ), - self.action == Action.CANDLES.value, ], ) diff --git a/tests/jewcal/test_core.py b/tests/jewcal/test_core.py index 158e089..28ffd8a 100644 --- a/tests/jewcal/test_core.py +++ b/tests/jewcal/test_core.py @@ -1,6 +1,6 @@ """Unittests for jewcal.core.""" -from datetime import date +from datetime import date, datetime, timezone from doctest import NORMALIZE_WHITESPACE, DocTestSuite from typing import no_type_check from unittest import TestCase @@ -221,6 +221,30 @@ def test_hadlokas_haneiros_is_set(self, mock_today: Mock) -> None: raise TypeError self.assertIsNotNone(jewcal.zmanim.hadlokas_haneiros) + @patch('src.jewcal.models.zmanim.datetime_now', autospec=True) + @patch('src.jewcal.models.zmanim.date_today', autospec=True) + @patch('src.jewcal.core.date_today', autospec=True) + def test_hadlokas_haneiros_is_set_and_after_nightfall( + self, + mock_core_today: Mock, + mock_today: Mock, + mock_now: Mock, + ) -> None: + """Test has Hadlokas Haneiros, is after nightfall, has next Gregorian date.""" + lat, lon = 51.22047, 4.40026 # Antwerpen + location = Location(latitude=lat, longitude=lon) + + date_ = date(2024, 7, 25) + now_ = datetime(2024, 7, 25, 20, 42, tzinfo=timezone.utc) + mock_core_today.return_value = date_ + mock_today.return_value = date_ + mock_now.return_value = now_ + jewcal = JewCal(date_, location) + if not jewcal.zmanim: + raise TypeError + + 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: """Test Hadlokas Haneiros is not set.""" diff --git a/tests/jewcal/test_main.py b/tests/jewcal/test_main.py index 2f2ced3..3809bfd 100644 --- a/tests/jewcal/test_main.py +++ b/tests/jewcal/test_main.py @@ -3,6 +3,7 @@ import sys from io import StringIO from unittest import TestCase +from unittest.mock import patch from src.jewcal.__main__ import main @@ -12,12 +13,8 @@ class MainTestCase(TestCase): def test_main(self) -> None: """Test main().""" - # capture standard output by temporarily redirecting sys.stdout to a StringIO - # https://stackoverflow.com/a/34738440 - output = StringIO() # Create StringIO. - sys.stdout = output # Redirect stdout. - main() # Call function. - sys.stdout = sys.__stdout__ # Reset redirect. + with patch.object(sys, 'stdout', StringIO()) as output: + main() # Call function. self.assertIn('Today is', output.getvalue()) self.assertIn('JewCal(jewish_date=JewishDate(year=', output.getvalue())