@@ -21,6 +21,21 @@ def test_init_custom_timezone(self):
2121 source = CalendarSource (country = "PL" , timezone = "UTC" )
2222 assert source .timezone == "UTC"
2323
24+ def test_init_default_coordinates (self ):
25+ source = CalendarSource (country = "PL" )
26+ assert source .lat == COUNTRY_DATA ["PL" ]["lat" ]
27+ assert source .lon == COUNTRY_DATA ["PL" ]["lon" ]
28+
29+ def test_init_override_coordinates (self ):
30+ source = CalendarSource (country = "PL" , lat = 54.3520 , lon = 18.6466 )
31+ assert source .lat == 54.3520
32+ assert source .lon == 18.6466
33+
34+ def test_init_override_lat_only (self ):
35+ source = CalendarSource (country = "PL" , lat = 54.3520 )
36+ assert source .lat == 54.3520
37+ assert source .lon == COUNTRY_DATA ["PL" ]["lon" ]
38+
2439 def test_init_invalid_holidays_value (self ):
2540 with pytest .raises (ValueError , match = "Invalid holidays value" ):
2641 CalendarSource (country = "PL" , holidays = "invalid" )
@@ -168,6 +183,18 @@ def test_daylight_summer_longer(self):
168183 winter = source .fetch (pd .Timestamp ("2024-12-21" , tz = "UTC" ), pd .Timestamp ("2024-12-22" , tz = "UTC" ))
169184 assert summer ["daylight_hours" ].iloc [0 ] > winter ["daylight_hours" ].iloc [0 ]
170185
186+ def test_daylight_respects_coordinate_override (self ):
187+ # A more northern latitude has longer daylight at the summer solstice.
188+ warsaw = CalendarSource (country = "PL" , holidays = False , weekday = False , daylight = True )
189+ northern = CalendarSource (
190+ country = "PL" , holidays = False , weekday = False , daylight = True , lat = 59.3293 , lon = 18.0686
191+ )
192+ start = pd .Timestamp ("2024-06-21" , tz = "UTC" )
193+ end = pd .Timestamp ("2024-06-22" , tz = "UTC" )
194+ warsaw_df = warsaw .fetch (start , end )
195+ northern_df = northern .fetch (start , end )
196+ assert northern_df ["daylight_hours" ].iloc [0 ] > warsaw_df ["daylight_hours" ].iloc [0 ]
197+
171198
172199class TestPrefix :
173200 def test_custom_prefix (self ):
0 commit comments