Skip to content

Commit

Permalink
[US] testcase coverage fixed for US territories
Browse files Browse the repository at this point in the history
  • Loading branch information
PPsyrius committed Jan 27, 2024
1 parent 4c01137 commit 6593f14
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions holidays/countries/united_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def _add_christmas_eve_holiday(self):
)

def _populate_subdiv_holidays(self):
if PUBLIC not in self.categories:
return None

# Martin Luther King Jr. Day
if self._year >= 1986 and self.subdiv not in {"AL", "AR", "AZ", "GA", "ID", "MS", "NH"}:
self._add_holiday_3rd_mon_of_jan("Martin Luther King Jr. Day")
Expand Down
9 changes: 9 additions & 0 deletions tests/countries/test_american_samoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest import TestCase

from holidays.calendars.gregorian import DEC
from holidays.constants import NON_PUBLIC
from holidays.countries.american_samoa import HolidaysAS, AS, ASM
from tests.common import CommonCountryTests

Expand All @@ -29,3 +30,11 @@ def test_as_only(self):
"""Check for a holiday that is not returned by US unless the
subdivision is specified."""
self.assertIn("Christmas Eve (observed)", self.holidays.get_list(date(2017, DEC, 22)))

def test_non_public_holidays(self):
self.assertHolidays(
HolidaysAS(categories=NON_PUBLIC, years=2024),
("2024-02-14", "Valentine's Day"),
("2024-03-17", "St. Patrick's Day"),
("2024-10-31", "Halloween"),
)
9 changes: 9 additions & 0 deletions tests/countries/test_guam.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest import TestCase

from holidays.calendars.gregorian import MAR
from holidays.constants import NON_PUBLIC
from holidays.countries.guam import HolidaysGU, GU, GUM
from tests.common import CommonCountryTests

Expand All @@ -29,3 +30,11 @@ def test_gu_only(self):
"""Check for a holiday that is not returned by US unless the
subdivision is specified."""
self.assertIn("Guam Discovery Day", self.holidays.get_list(date(2016, MAR, 7)))

def test_non_public_holidays(self):
self.assertHolidays(
HolidaysGU(categories=NON_PUBLIC, years=2024),
("2024-02-14", "Valentine's Day"),
("2024-03-17", "St. Patrick's Day"),
("2024-10-31", "Halloween"),
)
9 changes: 9 additions & 0 deletions tests/countries/test_northern_mariana_islands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest import TestCase

from holidays.calendars.gregorian import MAR
from holidays.constants import NON_PUBLIC
from holidays.countries.northern_mariana_islands import HolidaysMP, MP, MNP
from tests.common import CommonCountryTests

Expand All @@ -29,3 +30,11 @@ def test_mp_only(self):
"""Check for a holiday that is not returned by US unless the
subdivision is specified."""
self.assertIn("Commonwealth Covenant Day", self.holidays.get_list(date(2022, MAR, 24)))

def test_non_public_holidays(self):
self.assertHolidays(
HolidaysMP(categories=NON_PUBLIC, years=2024),
("2024-02-14", "Valentine's Day"),
("2024-03-17", "St. Patrick's Day"),
("2024-10-31", "Halloween"),
)
9 changes: 9 additions & 0 deletions tests/countries/test_puerto_rico.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest import TestCase

from holidays.calendars.gregorian import NOV
from holidays.constants import NON_PUBLIC
from holidays.countries.puerto_rico import HolidaysPR, PR, PRI
from tests.common import CommonCountryTests

Expand All @@ -29,3 +30,11 @@ def test_pr_only(self):
"""Check for a holiday that is not returned by US unless the
subdivision is specified."""
self.assertIn("Discovery Day (observed)", self.holidays.get_list(date(2017, NOV, 20)))

def test_non_public_holidays(self):
self.assertHolidays(
HolidaysPR(categories=NON_PUBLIC, years=2024),
("2024-02-14", "Valentine's Day"),
("2024-03-17", "St. Patrick's Day"),
("2024-10-31", "Halloween"),
)
9 changes: 9 additions & 0 deletions tests/countries/test_united_states_minor_outlying_islands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from unittest import TestCase

from holidays.constants import NON_PUBLIC
from holidays.countries.united_states_minor_outlying_islands import HolidaysUM, UM, UMI
from tests.common import CommonCountryTests

Expand All @@ -25,3 +26,11 @@ def test_country_aliases(self):

def test_common(self):
self.assertIn("Christmas Day", self.holidays["2022-12-25"])

def test_non_public_holidays(self):
self.assertHolidays(
HolidaysUM(categories=NON_PUBLIC, years=2024),
("2024-02-14", "Valentine's Day"),
("2024-03-17", "St. Patrick's Day"),
("2024-10-31", "Halloween"),
)
9 changes: 9 additions & 0 deletions tests/countries/test_united_states_virgin_islands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest import TestCase

from holidays.calendars.gregorian import MAR
from holidays.constants import NON_PUBLIC
from holidays.countries.united_states_virgin_islands import HolidaysVI, VI, VIR
from tests.common import CommonCountryTests

Expand All @@ -29,3 +30,11 @@ def test_vi_only(self):
"""Check for a holiday that is not returned by US unless the
subdivision is specified."""
self.assertIn("Transfer Day", self.holidays.get_list(date(2020, MAR, 31)))

def test_non_public_holidays(self):
self.assertHolidays(
HolidaysVI(categories=NON_PUBLIC, years=2024),
("2024-02-14", "Valentine's Day"),
("2024-03-17", "St. Patrick's Day"),
("2024-10-31", "Halloween"),
)

0 comments on commit 6593f14

Please sign in to comment.