File: test_mauritius.py

package info (click to toggle)
python-holidays 0.86-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,296 kB
  • sloc: python: 117,830; javascript: 85; makefile: 59
file content (211 lines) | stat: -rw-r--r-- 7,373 bytes parent folder | download
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#  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.countries.mauritius import Mauritius
from tests.common import CommonCountryTests


class TestMauritius(CommonCountryTests, TestCase):
    @classmethod
    def setUpClass(cls):
        years = range(1988, 2050)
        super().setUpClass(Mauritius, years=years)
        cls.no_estimated_holidays = Mauritius(years=years, islamic_show_estimated=False)

    def test_special_holidays(self):
        self.assertHolidayName("Public Holiday", "2019-07-29", "2019-09-09")

    def test_new_years_day(self):
        self.assertHolidayName("New Year's Day", (f"{year}-01-01" for year in range(1988, 2050)))

    def test_day_after_new_years_day(self):
        self.assertHolidayName(
            "Day after New Year's Day", (f"{year}-01-02" for year in range(1988, 2050))
        )

    def test_abolition_of_slavery_day(self):
        self.assertHolidayName(
            "Abolition of Slavery", (f"{year}-02-01" for year in range(1988, 2050))
        )

    def test_independence_and_republic_day(self):
        self.assertHolidayName(
            "Independence and Republic Day", (f"{year}-03-12" for year in range(1988, 2050))
        )

    def test_labour_day(self):
        self.assertHolidayName("Labour Day", (f"{year}-05-01" for year in range(1988, 2050)))

    def test_assumption_day(self):
        name = "Assumption of the Blessed Virgin Mary"
        self.assertHolidayName(name, (f"{year}-08-15" for year in range(2016, 2050, 2)))
        self.assertNoHolidayName(name, range(1988, 2016), range(2017, 2050, 2))

    def test_all_saints_day(self):
        name = "All Saints' Day"
        self.assertHolidayName(
            name, (f"{year}-11-01" for year in (*range(1988, 2016), *range(2017, 2050, 2)))
        )
        self.assertNoHolidayName(name, range(2016, 2050, 2))

    def test_arrival_of_indentured_labourers_day(self):
        self.assertHolidayName(
            "Arrival of Indentured Labourers", (f"{year}-11-02" for year in range(1988, 2050))
        )

    def test_christmas_day(self):
        self.assertHolidayName("Christmas Day", (f"{year}-12-25" for year in range(1988, 2050)))

    def test_chinese_spring_festival(self):
        name = "Chinese Spring Festival"
        self.assertHolidayName(
            name,
            "2021-02-12",
            "2022-02-01",
            "2023-01-22",
            "2024-02-10",
            "2025-01-29",
        )
        self.assertHolidayName(name, range(1988, 2050))

    def test_eid_al_fitr(self):
        name = "Eid-ul-Fitr"
        self.assertHolidayName(
            name,
            "2021-05-14",
            "2022-05-03",
            "2023-04-22",
            "2024-04-11",
            "2025-04-01",
        )
        self.assertHolidayName(name, self.no_estimated_holidays, range(1988, 2050))

    def test_thaipusam(self):
        name = "Thaipoosam Cavadee"
        self.assertHolidayName(
            name,
            "2021-01-28",
            "2022-01-18",
            "2023-02-04",
            "2024-01-25",
            "2025-02-11",
        )
        self.assertHolidayName(name, range(1988, 2050))

    def test_maha_shivaratri(self):
        name = "Maha Shivaratree"
        self.assertHolidayName(
            name,
            "2021-03-11",
            "2022-03-01",
            "2023-02-18",
            "2024-03-08",
            "2025-02-26",
        )
        self.assertHolidayName(name, range(2001, 2036))

    def test_ougadi(self):
        name = "Ougadi"
        self.assertHolidayName(
            name,
            "2021-04-13",
            "2022-04-02",
            "2023-03-22",
            "2024-04-09",
            "2025-03-30",
        )
        self.assertHolidayName(name, range(2001, 2036))

    def test_ganesh_chaturthi(self):
        name = "Ganesh Chaturthi"
        self.assertHolidayName(
            name,
            "2021-09-11",
            "2022-09-01",
            "2023-09-20",
            "2024-09-08",
            "2025-08-28",
        )
        self.assertHolidayName(name, range(2001, 2036))

    def test_diwali(self):
        name = "Divali"
        self.assertHolidayName(
            name,
            "2021-11-04",
            "2022-10-24",
            "2023-11-12",
            "2024-10-31",
            "2025-10-20",
        )
        self.assertHolidayName(name, range(2001, 2036))

    def test_2024(self):
        self.assertHolidaysInYear(
            2024,
            ("2024-01-01", "New Year's Day"),
            ("2024-01-02", "Day after New Year's Day"),
            ("2024-01-25", "Thaipoosam Cavadee"),
            ("2024-02-01", "Abolition of Slavery"),
            ("2024-02-10", "Chinese Spring Festival"),
            ("2024-03-08", "Maha Shivaratree"),
            ("2024-03-12", "Independence and Republic Day"),
            ("2024-04-09", "Ougadi"),
            ("2024-04-11", "Eid-ul-Fitr"),
            ("2024-05-01", "Labour Day"),
            ("2024-08-15", "Assumption of the Blessed Virgin Mary"),
            ("2024-09-08", "Ganesh Chaturthi"),
            ("2024-10-31", "Divali"),
            ("2024-11-02", "Arrival of Indentured Labourers"),
            ("2024-12-25", "Christmas Day"),
        )

    def test_l10n_default(self):
        self.assertLocalizedHolidays(
            ("2025-01-01", "New Year's Day"),
            ("2025-01-02", "Day after New Year's Day"),
            ("2025-01-29", "Chinese Spring Festival"),
            ("2025-02-01", "Abolition of Slavery"),
            ("2025-02-11", "Thaipoosam Cavadee"),
            ("2025-02-26", "Maha Shivaratree"),
            ("2025-03-12", "Independence and Republic Day"),
            ("2025-03-30", "Ougadi"),
            ("2025-04-01", "Eid-ul-Fitr"),
            ("2025-05-01", "Labour Day"),
            ("2025-08-28", "Ganesh Chaturthi"),
            ("2025-10-20", "Divali"),
            ("2025-11-01", "All Saints' Day"),
            ("2025-11-02", "Arrival of Indentured Labourers"),
            ("2025-12-25", "Christmas Day"),
        )

    def test_l10n_en_us(self):
        self.assertLocalizedHolidays(
            "en_US",
            ("2025-01-01", "New Year's Day"),
            ("2025-01-02", "Day after New Year's Day"),
            ("2025-01-29", "Chinese Spring Festival"),
            ("2025-02-01", "Abolition of Slavery"),
            ("2025-02-11", "Thaipusam"),
            ("2025-02-26", "Maha Shivaratri"),
            ("2025-03-12", "Independence and Republic Day"),
            ("2025-03-30", "Ugadi"),
            ("2025-04-01", "Eid al-Fitr"),
            ("2025-05-01", "Labor Day"),
            ("2025-08-28", "Ganesh Chaturthi"),
            ("2025-10-20", "Diwali"),
            ("2025-11-01", "All Saints' Day"),
            ("2025-11-02", "Arrival of Indentured Laborers"),
            ("2025-12-25", "Christmas Day"),
        )