File: test_zimbabwe.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 (132 lines) | stat: -rw-r--r-- 4,071 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
#  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.zimbabwe import Zimbabwe
from tests.common import CommonCountryTests


class TestZimbabwe(CommonCountryTests, TestCase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass(Zimbabwe, years=range(1988, 2050))

    def test_holidays(self):
        for year in range(1988, 2050):
            self.assertHoliday(
                f"{year}-01-01",
                f"{year}-04-18",
                f"{year}-05-01",
                f"{year}-05-25",
                f"{year}-12-22",
                f"{year}-12-25",
                f"{year}-12-26",
            )

        self.assertNoHoliday(f"{year}-02-21" for year in range(1988, 2018))
        self.assertNoHolidayName("Robert Gabriel Mugabe National Youth Day", range(1988, 2018))
        self.assertHoliday(f"{year}-02-21" for year in range(2018, 2050))

    def test_easter(self):
        self.assertHoliday(
            # Good Friday
            "2018-03-30",
            "2019-04-19",
            "2020-04-10",
            "2021-04-02",
            "2022-04-15",
            # Holy Saturday
            "2018-03-31",
            "2019-04-20",
            "2020-04-11",
            "2021-04-03",
            "2022-04-16",
            # Easter Monday
            "2018-04-02",
            "2019-04-22",
            "2020-04-13",
            "2021-04-05",
            "2022-04-18",
        )

    def test_moving_holidays(self):
        self.assertHoliday(
            # Zimbabwe Heroes' Day
            "2018-08-13",
            "2019-08-12",
            "2020-08-10",
            "2021-08-09",
            "2022-08-08",
            # Defense Forces Day
            "2018-08-14",
            "2019-08-13",
            "2020-08-11",
            "2021-08-10",
            "2022-08-09",
        )

    def test_observed(self):
        dt = (
            "2002-12-23",
            "2003-05-26",
            "2004-04-19",
            "2004-12-27",
            "2005-05-02",
            "2005-12-27",
            "2006-01-02",
            "2008-05-26",
            "2010-04-19",
            "2010-12-27",
            "2011-05-02",
            "2011-12-27",
            "2012-01-02",
            "2013-12-23",
            "2014-05-26",
            "2016-05-02",
            "2016-12-27",
            "2017-01-02",
            "2019-12-23",
            "2021-02-22",
            "2021-04-19",
            "2021-12-27",
            "2022-05-02",
            "2022-12-27",
            "2023-01-02",
            "2024-12-23",
            "2027-02-22",
            # special cases
            "2049-04-20",
            "2055-04-20",
            "2060-04-20",
        )
        self.assertHoliday(dt)
        self.assertNoNonObservedHoliday(dt)

    def test_2022(self):
        self.assertHolidaysInYear(
            2022,
            ("2022-01-01", "New Year's Day"),
            ("2022-02-21", "Robert Gabriel Mugabe National Youth Day"),
            ("2022-04-15", "Good Friday"),
            ("2022-04-16", "Easter Saturday"),
            ("2022-04-18", "Easter Monday; Independence Day"),
            ("2022-05-01", "Workers' Day"),
            ("2022-05-02", "Workers' Day (observed)"),
            ("2022-05-25", "Africa Day"),
            ("2022-08-08", "Zimbabwe Heroes' Day"),
            ("2022-08-09", "Defense Forces Day"),
            ("2022-12-22", "Unity Day"),
            ("2022-12-25", "Christmas Day"),
            ("2022-12-26", "Boxing Day"),
            ("2022-12-27", "Christmas Day (observed)"),
        )