Skip to content

Commit ba81c64

Browse files
Updated test_pitcairn_islands.py
1 parent ff75003 commit ba81c64

File tree

1 file changed

+22
-129
lines changed

1 file changed

+22
-129
lines changed

tests/countries/test_pitcairn_islands.py

Lines changed: 22 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -52,136 +52,29 @@ def test_2025(self):
5252
("2025-12-26", "Boxing Day"),
5353
)
5454

55-
def test_kings_birthday_calculation(self):
56-
"""Test that King's Birthday is always the 2nd Saturday in June."""
57-
test_years = [2020, 2021, 2022, 2023, 2024, 2025, 2026]
58-
59-
for year in test_years:
60-
holidays = PitcairnIslands(years=year)
61-
62-
# Find the King's Birthday date
63-
kings_birthday_date = None
64-
for holiday_date, holiday_name in holidays.items():
65-
if "Birthday" in holiday_name:
66-
kings_birthday_date = holiday_date
67-
break
68-
69-
self.assertIsNotNone(
70-
kings_birthday_date, f"King's/Queen's Birthday not found in {year}"
71-
)
72-
73-
# Verify it's in June
74-
self.assertEqual(
75-
kings_birthday_date.month, 6, f"King's/Queen's Birthday not in June for {year}"
76-
)
77-
78-
# Verify it's a Saturday (weekday() returns 5 for Saturday)
79-
self.assertEqual(
80-
kings_birthday_date.weekday(),
81-
5,
82-
f"King's/Queen's Birthday not on Saturday for {year}",
83-
)
84-
85-
# Verify it's between 8th and 14th (2nd Saturday range)
86-
self.assertGreaterEqual(
87-
kings_birthday_date.day, 8, f"King's/Queen's Birthday too early for {year}"
88-
)
89-
self.assertLessEqual(
90-
kings_birthday_date.day, 14, f"King's/Queen's Birthday too late for {year}"
91-
)
92-
93-
def test_bounty_day_fixed_date(self):
94-
"""Test that Bounty Day is always January 23."""
95-
test_years = [2020, 2021, 2022, 2023, 2024, 2025]
96-
97-
for year in test_years:
98-
holidays = PitcairnIslands(years=year)
99-
expected_date = date(year, 1, 23)
100-
101-
self.assertIn(expected_date, holidays, f"Bounty Day missing for {year}")
102-
self.assertEqual(
103-
holidays[expected_date], "Bounty Day", f"Wrong name for Bounty Day in {year}"
104-
)
105-
106-
def test_christian_holidays(self):
107-
"""Test that Christian holidays are calculated correctly."""
108-
holidays = PitcairnIslands(years=2024)
109-
110-
# Good Friday should be 2 days before Easter Sunday
111-
good_friday = date(2024, 3, 29)
112-
easter_monday = date(2024, 4, 1)
113-
114-
self.assertIn(good_friday, holidays)
115-
self.assertIn(easter_monday, holidays)
116-
self.assertEqual(holidays[good_friday], "Good Friday")
117-
self.assertEqual(holidays[easter_monday], "Easter Monday")
118-
119-
# Verify the relationship between Good Friday and Easter Monday
120-
self.assertEqual((easter_monday - good_friday).days, 3)
121-
122-
def test_holiday_count_consistency(self):
123-
"""Test that the number of holidays is consistent across years."""
124-
expected_count = 7 # 7 regular holidays
125-
126-
test_years = [2020, 2021, 2022, 2023, 2024, 2025]
127-
for year in test_years:
128-
holidays = PitcairnIslands(years=year)
129-
# Allow for observed holidays (weekends may add extra days)
130-
self.assertGreaterEqual(
131-
len(holidays), expected_count, f"Too few holidays in {year}: {len(holidays)}"
132-
)
133-
self.assertLessEqual(
134-
len(holidays), expected_count + 2, f"Too many holidays in {year}: {len(holidays)}"
135-
)
136-
137-
def test_alias_classes_equivalence(self):
138-
"""Test that alias classes produce identical results."""
139-
year = 2024
140-
141-
pitcairn = PitcairnIslands(years=year)
142-
pn = PN(years=year)
143-
pcn = PCN(years=year)
144-
145-
# All should have the same holidays
146-
self.assertEqual(dict(pitcairn), dict(pn), "PitcairnIslands and PN differ")
147-
self.assertEqual(dict(pitcairn), dict(pcn), "PitcairnIslands and PCN differ")
148-
self.assertEqual(dict(pn), dict(pcn), "PN and PCN differ")
149-
150-
def test_random_non_holiday(self):
151-
self.assertNoHoliday(PitcairnIslands(years=2024), date(2024, 2, 2))
152-
153-
def test_multiple_random_non_holidays(self):
154-
"""Test multiple dates that should not be holidays."""
155-
holidays = PitcairnIslands(years=2024)
55+
def test_kings_birthday(self):
56+
"""Test King's Birthday holiday."""
57+
# Test specific known dates
58+
self.assertHolidayName("King's Birthday", "2024-06-08", "2025-06-14")
59+
# Test Queen's Birthday for earlier years
60+
self.assertHolidayName("Queen's Birthday", "2022-06-11")
61+
62+
def test_bounty_day(self):
63+
"""Test Bounty Day holiday."""
64+
self.assertHolidayName(
65+
"Bounty Day", (f"{year}-01-23" for year in range(2000, 2050))
66+
)
15667

157-
non_holiday_dates = [
158-
date(2024, 2, 14), # Valentine's Day
159-
date(2024, 3, 17), # St. Patrick's Day
160-
date(2024, 7, 4), # US Independence Day
161-
date(2024, 10, 31), # Halloween
162-
date(2024, 11, 11), # Remembrance Day
163-
]
68+
def test_good_friday(self):
69+
"""Test Good Friday holiday."""
70+
self.assertHolidayName("Good Friday", "2024-03-29", "2025-04-18")
16471

165-
for test_date in non_holiday_dates:
166-
self.assertNotIn(test_date, holidays, f"{test_date} should not be a holiday")
72+
def test_easter_monday(self):
73+
"""Test Easter Monday holiday."""
74+
self.assertHolidayName("Easter Monday", "2024-04-01", "2025-04-21")
16775

16876
def test_monarch_birthday_naming(self):
169-
"""Test that monarch's birthday uses correct title based on year."""
170-
171-
# Test Queen's Birthday (before 2023)
172-
holidays_2022 = PitcairnIslands(years=2022)
173-
queen_birthday = None
174-
for _, name in holidays_2022.items():
175-
if "Birthday" in name:
176-
queen_birthday = name
177-
break
178-
self.assertEqual(queen_birthday, "Queen's Birthday")
179-
180-
# Test King's Birthday (from 2023 onwards)
181-
holidays_2023 = PitcairnIslands(years=2023)
182-
king_birthday = None
183-
for _, name in holidays_2023.items():
184-
if "Birthday" in name:
185-
king_birthday = name
186-
break
187-
self.assertEqual(king_birthday, "King's Birthday")
77+
+ """Test that monarch's birthday uses correct title based on year."""
78+
# Test Queen's Birthday (before 2023) and King's Birthday (from 2023)
79+
+ self.assertHolidayName("Queen's Birthday", "2022-06-11")
80+
self.assertHolidayName("King's Birthday", "2023-06-10")

0 commit comments

Comments
 (0)