test: improve test for local holidays

(cherry picked from commit 60329ade9e)
This commit is contained in:
barredterra
2024-01-04 11:04:25 +01:00
committed by Mergify
parent 3180266150
commit f3d8d273f4

View File

@@ -48,17 +48,58 @@ class TestHolidayList(unittest.TestCase):
def test_local_holidays(self):
holiday_list = frappe.new_doc("Holiday List")
holiday_list.from_date = "2023-04-01"
holiday_list.to_date = "2023-04-30"
holiday_list.from_date = "2022-01-01"
holiday_list.to_date = "2024-12-31"
holiday_list.country = "DE"
holiday_list.subdivision = "SN"
holiday_list.get_local_holidays()
holidays = [holiday.holiday_date for holiday in holiday_list.holidays]
self.assertNotIn(date(2023, 1, 1), holidays)
holidays = holiday_list.get_holidays()
self.assertIn(date(2022, 1, 1), holidays)
self.assertIn(date(2022, 4, 15), holidays)
self.assertIn(date(2022, 4, 18), holidays)
self.assertIn(date(2022, 5, 1), holidays)
self.assertIn(date(2022, 5, 26), holidays)
self.assertIn(date(2022, 6, 6), holidays)
self.assertIn(date(2022, 10, 3), holidays)
self.assertIn(date(2022, 10, 31), holidays)
self.assertIn(date(2022, 11, 16), holidays)
self.assertIn(date(2022, 12, 25), holidays)
self.assertIn(date(2022, 12, 26), holidays)
self.assertIn(date(2023, 1, 1), holidays)
self.assertIn(date(2023, 4, 7), holidays)
self.assertIn(date(2023, 4, 10), holidays)
self.assertNotIn(date(2023, 5, 1), holidays)
self.assertIn(date(2023, 5, 1), holidays)
self.assertIn(date(2023, 5, 18), holidays)
self.assertIn(date(2023, 5, 29), holidays)
self.assertIn(date(2023, 10, 3), holidays)
self.assertIn(date(2023, 10, 31), holidays)
self.assertIn(date(2023, 11, 22), holidays)
self.assertIn(date(2023, 12, 25), holidays)
self.assertIn(date(2023, 12, 26), holidays)
self.assertIn(date(2024, 1, 1), holidays)
self.assertIn(date(2024, 3, 29), holidays)
self.assertIn(date(2024, 4, 1), holidays)
self.assertIn(date(2024, 5, 1), holidays)
self.assertIn(date(2024, 5, 9), holidays)
self.assertIn(date(2024, 5, 20), holidays)
self.assertIn(date(2024, 10, 3), holidays)
self.assertIn(date(2024, 10, 31), holidays)
self.assertIn(date(2024, 11, 20), holidays)
self.assertIn(date(2024, 12, 25), holidays)
self.assertIn(date(2024, 12, 26), holidays)
# check some random dates that should not be local holidays
self.assertNotIn(date(2022, 1, 2), holidays)
self.assertNotIn(date(2023, 4, 16), holidays)
self.assertNotIn(date(2024, 4, 19), holidays)
self.assertNotIn(date(2022, 5, 2), holidays)
self.assertNotIn(date(2023, 5, 27), holidays)
self.assertNotIn(date(2024, 6, 7), holidays)
self.assertNotIn(date(2022, 10, 4), holidays)
self.assertNotIn(date(2023, 10, 30), holidays)
self.assertNotIn(date(2024, 11, 17), holidays)
self.assertNotIn(date(2022, 12, 24), holidays)
def test_localized_country_names(self):
lang = frappe.local.lang