1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
# holidays
# --------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file)
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/holidays
# License: MIT (see LICENSE file)
from unittest import TestCase
from holidays.calendars.thai import KHMER_CALENDAR
from holidays.groups import (
BalineseSakaCalendarHolidays,
ChristianHolidays,
InternationalHolidays,
PersianCalendarHolidays,
ThaiCalendarHolidays,
)
from holidays.holiday_base import HolidayBase
class TestBalineseSakaCalendarHolidays(TestCase):
def test_add_balinese_saka_calendar_holiday(self):
# Check for out-of-range dates.
class TestHolidays(HolidayBase, BalineseSakaCalendarHolidays):
end_year = 2051
def __init__(self, *args, **kwargs):
BalineseSakaCalendarHolidays.__init__(self)
super().__init__(*args, **kwargs)
test_holidays = TestHolidays()
test_holidays._populate(2051)
test_holidays._add_nyepi("Day of Silence")
self.assertEqual(0, len(test_holidays))
class TestChristianHolidays(TestCase):
def test_check_calendar(self):
self.assertRaises(ValueError, lambda: ChristianHolidays("INVALID_CALENDAR"))
def test_add_christmas_day_three(self):
class TestHolidays(HolidayBase, ChristianHolidays):
def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
super().__init__(*args, **kwargs)
def _populate(self, year):
super()._populate(year)
test_holidays = TestHolidays()
test_holidays._populate(2022)
test_holidays._add_christmas_day_three("Third day")
self.assertIn("2022-12-27", test_holidays)
self.assertEqual(1, len(test_holidays))
class TestInternationalHolidays(TestCase):
def test_add_childrens_day(self):
class TestHolidays(HolidayBase, InternationalHolidays):
def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
super().__init__(*args, **kwargs)
test_holidays = TestHolidays()
test_holidays._populate(2022)
test_holidays._add_childrens_day("Children's Day (November 20)", "NOV")
self.assertIn("2022-11-20", test_holidays)
self.assertEqual(1, len(test_holidays))
self.assertRaises(
ValueError, lambda: test_holidays._add_childrens_day("Invalid", "INVALID_TYPE")
)
class TestPersianCalendarHolidays(TestCase):
def test_add_persian_calendar_holiday(self):
# Check for out-of-range dates.
class TestHolidays(HolidayBase, PersianCalendarHolidays):
end_year = 2102
def __init__(self, *args, **kwargs):
PersianCalendarHolidays.__init__(self)
super().__init__(*args, **kwargs)
test_holidays = TestHolidays()
test_holidays._populate(2102)
test_holidays._add_nowruz_day("Persian New Year")
test_holidays._add_islamic_republic_day("Islamic Republic Day")
test_holidays._add_natures_day("Nature's Day")
test_holidays._add_death_of_khomeini_day("Death of Khomeini")
test_holidays._add_khordad_uprising_day("Khordad National Uprising")
test_holidays._add_islamic_revolution_day("Islamic Revolution Day")
test_holidays._add_oil_nationalization_day("Iranian Oil Industry Nationalization Day")
self.assertEqual(0, len(test_holidays))
class TestThaiCalendarHolidays(TestCase):
def test_add_thai_calendar_holiday(self):
# Check for out-of-range dates.
class TestHolidays(HolidayBase, ThaiCalendarHolidays):
end_year = 2158
def __init__(self, *args, **kwargs):
ThaiCalendarHolidays.__init__(self)
super().__init__(*args, **kwargs)
test_holidays = TestHolidays()
test_holidays._populate(2158)
test_holidays._add_asarnha_bucha("Asarnha Bucha")
test_holidays._add_boun_haw_khao_padapdin("Boun Haw Khao Padapdin")
test_holidays._add_boun_haw_khao_salark("Boun Haw Khao Salark")
test_holidays._add_boun_suang_heua("Boun Suang Huea")
test_holidays._add_khao_phansa("Khao Phansa")
test_holidays._add_loy_krathong("Loy Krathong")
test_holidays._add_makha_bucha("Makha Bucha")
test_holidays._add_makha_bucha("Meak Bochea", KHMER_CALENDAR)
test_holidays._add_ok_phansa("Ok Phansa")
test_holidays._add_pchum_ben("Pchum Ben")
test_holidays._add_preah_neangkoal("Royal Ploughing Ceremony (Cambodia)")
test_holidays._add_visakha_bucha("Visakha Bucha")
test_holidays._add_visakha_bucha("Visaka Bochea", KHMER_CALENDAR)
self.assertEqual(0, len(test_holidays))
|