Repository: peopledoc/workalendar
Pull request #542 (2020-09-02 14:19:09)

Mozambique
added Mozambique calendar
added tests
updated readme
updated changelog (did not know what to fill in with the (#) part

mr-shovel: Fixed your comments
ewjoachim: Hey :)

I think you have updated the **project**'s gitignore file.
What @brunobord suggested was to setup your **own** personal gitignore file, which would allow not needing every project you work on to make a special case for people with this IDE.

Here's the command you can run:
```console
$ echo .vscode > ~/.gitignoreglobal
$ git config --global core.excludesfile ~/.gitignoreglobal
```
mr-shovel: @ewjoachim @brunobord  Thanks for the remarks, learned a thing again today! Anything else needs resolving?

ewjoachim: I'm still seeing a diff on the .gitignore file. Is it intended?

(Thanks a lot for the contribution by the way)
mr-shovel: You're welcome:) I've removed the .vscode line from the gitignore. the .vscode folder should still be excluded.

Patch:
diff --git a/Changelog.md b/Changelog.md
index a1b6212..ecc2a99 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,7 +2,10 @@
 
 ## master (unreleased)
 
-Nothing here yet.
+### New calendar
+
+- Added Mozambique calendar by @mr-shovel (#542).
+
 
 ## v10.4.0 (2020-08-28)
 
diff --git a/README.rst b/README.rst
index 5376014..99d2225 100644
--- a/README.rst
+++ b/README.rst
@@ -170,9 +170,11 @@ Africa
 * Ivory Coast
 * Kenya
 * Madagascar
+* Mozambique
 * São Tomé
 * South Africa
 
+
 And more to come (I hope!)
 
 Caveats
diff --git a/workalendar/africa/__init__.py b/workalendar/africa/__init__.py
index bfb31a6..9e805f6 100644
--- a/workalendar/africa/__init__.py
+++ b/workalendar/africa/__init__.py
@@ -6,7 +6,7 @@ from .madagascar import Madagascar
 from .sao_tome import SaoTomeAndPrincipe
 from .south_africa import SouthAfrica
 from .angola import Angola
-
+from .mozambique import Mozambique
 
 __all__ = (
     'Algeria',
@@ -17,4 +17,5 @@ __all__ = (
     'SaoTomeAndPrincipe',
     'SouthAfrica',
     'Angola',
+    'Mozambique',
 )
diff --git a/workalendar/africa/mozambique.py b/workalendar/africa/mozambique.py
new file mode 100644
index 0000000..10bd975
--- /dev/null
+++ b/workalendar/africa/mozambique.py
@@ -0,0 +1,22 @@
+from ..core import WesternCalendar
+from ..registry_tools import iso_register
+
+
+@iso_register('MZ')
+class Mozambique(WesternCalendar):
+    "Mozambique"
+    FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + (
+        (2, 3, "Mozambican Heroes' Day"),
+        (4, 7, "Mozambican Women's Day"),
+        (6, 25, "Independence Day"),
+        (9, 7, "Victory Day"),
+        (9, 25, "Armed Forces Day"),
+        (10, 4, "Peace And Reconciliation Day"),
+    )
+
+    # Civil holidays
+    include_labour_day = True
+
+    # Christian holidays
+    include_good_friday = True
+    include_christmas = True


Test patch:
diff --git a/workalendar/tests/test_mozambique.py b/workalendar/tests/test_mozambique.py
new file mode 100644
index 0000000..0f68b87
--- /dev/null
+++ b/workalendar/tests/test_mozambique.py
@@ -0,0 +1,154 @@
+from datetime import date
+
+from . import GenericCalendarTest
+from ..africa.mozambique import Mozambique
+
+
+class MozambiqueTest(GenericCalendarTest):
+    cal_class = Mozambique
+
+    def test_year_new_year_shift(self):
+        holidays = self.cal.holidays_set(2019)
+        self.assertIn(date(2019, 1, 1), holidays)
+        self.assertNotIn(date(2019, 1, 2), holidays)
+        holidays = self.cal.holidays_set(2020)
+        self.assertIn(date(2020, 1, 1), holidays)
+        self.assertNotIn(date(2020, 1, 2), holidays)
+
+    def test_n_holidays(self):
+        n_holidays = len(self.cal.holidays_set(2019))
+        for holiday in self.cal.get_calendar_holidays(2020):
+            print(holiday)
+        assert n_holidays == 10
+
+    def test_year_2018(self):
+        holidays = self.cal.holidays_set(2018)
+        # Fixed days section:
+        # 1. New Year's Day
+        self.assertIn(date(2018, 1, 1), holidays)
+        # 2. Mozambican Heroes' Day
+        self.assertIn(date(2018, 2, 3), holidays)
+        # 3. Mozambican Women's Day
+        self.assertIn(date(2018, 4, 7), holidays)
+        # 4. Good Friday
+        self.assertIn(date(2018, 3, 30), holidays)
+        # 5. Labour Day
+        self.assertIn(date(2018, 5, 1), holidays)
+        # 6. Independence Day
+        self.assertIn(date(2018, 6, 25), holidays)
+        # 7. Victory Day
+        self.assertIn(date(2018, 9, 7), holidays)
+        # 8. Armed Forces Day
+        self.assertIn(date(2018, 9, 25), holidays)
+        # 9. Peace And Reconciliation Day
+        self.assertIn(date(2018, 10, 4), holidays)
+        # 10. Christmas day
+        self.assertIn(date(2018, 12, 25), holidays)
+
+    def test_year_2019(self):
+        holidays = self.cal.holidays_set(2019)
+        # Fixed days section:
+        # 1. New Year's Day
+        self.assertIn(date(2019, 1, 1), holidays)
+        # 2. Mozambican Heroes' Day
+        self.assertIn(date(2019, 2, 3), holidays)
+        # 3. Mozambican Women's Day
+        self.assertIn(date(2019, 4, 7), holidays)
+        # 4. Good Friday
+        self.assertIn(date(2019, 4, 19), holidays)
+        # 5. Labour Day
+        self.assertIn(date(2019, 5, 1), holidays)
+        # 6. Independence Day
+        self.assertIn(date(2019, 6, 25), holidays)
+        # 7. Victory Day
+        self.assertIn(date(2019, 9, 7), holidays)
+        # 8. Armed Forces Day
+        self.assertIn(date(2019, 9, 25), holidays)
+        # 9. Peace And Reconciliation Day
+        self.assertIn(date(2019, 10, 4), holidays)
+        # 10. Christmas day
+        self.assertIn(date(2019, 12, 25), holidays)
+
+    def test_year_2020(self):
+        holidays = self.cal.holidays_set(2020)
+        # Fixed days section:
+        # 1. New Year's Day
+        self.assertIn(date(2020, 1, 1), holidays)
+        # 2. Mozambican Heroes' Day
+        self.assertIn(date(2020, 2, 3), holidays)
+        # 3. Mozambican Women's Day
+        self.assertIn(date(2020, 4, 7), holidays)
+        # 4. Good Friday
+        self.assertIn(date(2020, 4, 10), holidays)
+        # 5. Labour Day
+        self.assertIn(date(2020, 5, 1), holidays)
+        # 6. Independence Day
+        self.assertIn(date(2020, 6, 25), holidays)
+        # 7. Victory Day
+        self.assertIn(date(2020, 9, 7), holidays)
+        # 8. Armed Forces Day
+        self.assertIn(date(2020, 9, 25), holidays)
+        # 9. Peace And Reconciliation Day
+        self.assertIn(date(2020, 10, 4), holidays)
+        # 10. Christmas day
+        self.assertIn(date(2020, 12, 25), holidays)
+
+    def test_2020_new_years_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 1, 1)], "New year")
+
+    def test_2020_heroes_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 2, 3)], "Mozambican Heroes' Day")
+
+    def test_2020_women_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 4, 7)], "Mozambican Women's Day")
+
+    def test_2020_good_friday_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 4, 10)], "Good Friday")
+
+    def test_2020_labour_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 5, 1)], "Labour Day")
+
+    def test_2020_independence_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 6, 25)], "Independence Day")
+
+    def test_2020_victory_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 9, 7)], "Victory Day")
+
+    def test_2020_armed_forces_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 9, 25)], "Armed Forces Day")
+
+    def test_2020_peace_and_reconciliation_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 10, 4)], "Peace And Reconciliation Day")
+
+    def test_2020_christmas_day_label(self):
+        holidays = self.cal.holidays(2020)
+        holidays = dict(holidays)
+        self.assertEqual(
+            holidays[date(2020, 12, 25)], "Christmas Day")