From 6593f1424756d072978875f8bf95468b54cf9c75 Mon Sep 17 00:00:00 2001 From: PPsyrius <19505219+PPsyrius@users.noreply.github.com> Date: Sat, 27 Jan 2024 00:23:03 +0700 Subject: [PATCH] [US] testcase coverage fixed for US territories --- holidays/countries/united_states.py | 3 +++ tests/countries/test_american_samoa.py | 9 +++++++++ tests/countries/test_guam.py | 9 +++++++++ tests/countries/test_northern_mariana_islands.py | 9 +++++++++ tests/countries/test_puerto_rico.py | 9 +++++++++ .../test_united_states_minor_outlying_islands.py | 9 +++++++++ tests/countries/test_united_states_virgin_islands.py | 9 +++++++++ 7 files changed, 57 insertions(+) diff --git a/holidays/countries/united_states.py b/holidays/countries/united_states.py index d231bdaf9..280c7ccdf 100644 --- a/holidays/countries/united_states.py +++ b/holidays/countries/united_states.py @@ -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") diff --git a/tests/countries/test_american_samoa.py b/tests/countries/test_american_samoa.py index db6772987..95fbe46e3 100644 --- a/tests/countries/test_american_samoa.py +++ b/tests/countries/test_american_samoa.py @@ -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 @@ -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"), + ) diff --git a/tests/countries/test_guam.py b/tests/countries/test_guam.py index e39cf83c3..12841a999 100644 --- a/tests/countries/test_guam.py +++ b/tests/countries/test_guam.py @@ -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 @@ -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"), + ) diff --git a/tests/countries/test_northern_mariana_islands.py b/tests/countries/test_northern_mariana_islands.py index 24889a2e9..46a6f3300 100644 --- a/tests/countries/test_northern_mariana_islands.py +++ b/tests/countries/test_northern_mariana_islands.py @@ -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 @@ -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"), + ) diff --git a/tests/countries/test_puerto_rico.py b/tests/countries/test_puerto_rico.py index 31180b844..1abc60543 100644 --- a/tests/countries/test_puerto_rico.py +++ b/tests/countries/test_puerto_rico.py @@ -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 @@ -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"), + ) diff --git a/tests/countries/test_united_states_minor_outlying_islands.py b/tests/countries/test_united_states_minor_outlying_islands.py index 51e03e06d..98635d7c0 100644 --- a/tests/countries/test_united_states_minor_outlying_islands.py +++ b/tests/countries/test_united_states_minor_outlying_islands.py @@ -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 @@ -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"), + ) diff --git a/tests/countries/test_united_states_virgin_islands.py b/tests/countries/test_united_states_virgin_islands.py index 4a32d2259..71a50a42c 100644 --- a/tests/countries/test_united_states_virgin_islands.py +++ b/tests/countries/test_united_states_virgin_islands.py @@ -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 @@ -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"), + )