Repository: peopledoc/workalendar
Pull request #553 (2020-09-11 14:42:06)

Add ISO code decorator to Catalonia calendar
refs #551 / superseeds and thus, closes #552 -- based on the cool contrib by @jbagot

- [x] Tests with a significant number of years to be tested for your calendar.
- [x] Changelog amended with a mention describing your changes.



Patch:
diff --git a/Changelog.md b/Changelog.md
index 8bb4e20..e16c951 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,7 @@
 
 ## master (unreleased)
 
+- Add ISO code decorator to Catalonia calendar, thanks to @jbagot (#551).
 - Improve coverage of South Africa calendar (#546).
 - Improve coverage of Brazil calendar (#546).
 - Improve coverage of Canada (Nunavut) calendar (#546).
diff --git a/workalendar/europe/spain.py b/workalendar/europe/spain.py
index a915a9f..3654719 100644
--- a/workalendar/europe/spain.py
+++ b/workalendar/europe/spain.py
@@ -22,6 +22,7 @@ class Spain(WesternCalendar):
     )
 
 
+@iso_register('ES-CT')
 class Catalonia(Spain):
     "Catalonia"
 


Test patch:
diff --git a/workalendar/tests/test_registry_europe.py b/workalendar/tests/test_registry_europe.py
index 1e801ab..6fd2268 100644
--- a/workalendar/tests/test_registry_europe.py
+++ b/workalendar/tests/test_registry_europe.py
@@ -5,8 +5,7 @@ from ..europe import (
     # FranceAlsaceMoselle,  # TODO: Should we add it to the registry?
     Greece, Hungary, Iceland, Ireland, Italy, Latvia, Lithuania, Luxembourg,
     Malta, Monaco, Netherlands, Norway, Poland, Portugal, Romania, Russia,
-    Slovakia, Slovenia, Spain,
-    # Catalonia,  # TODO: Add it to registry
+    Slovakia, Slovenia, Spain, Catalonia,
     Sweden, UnitedKingdom,
     UnitedKingdomNorthernIreland,
 )
@@ -47,6 +46,10 @@ SWITZERLAND_REGION_CLASSES = (
     Ticino, Uri, Vaud, Valais, Zug, Zurich
 )
 
+SPAIN_REGION_CLASSES = (
+    Catalonia,
+)
+
 
 class RegistryEurope(TestCase):
     def test_europe(self):
@@ -91,21 +94,30 @@ class RegistryEurope(TestCase):
             self.assertIn(klass, classes)
         for klass in SWITZERLAND_REGION_CLASSES:
             self.assertIn(klass, classes)
+        for klass in SPAIN_REGION_CLASSES:
+            self.assertIn(klass, classes)
 
-    def test_germany_subregion(self):
+    def test_germany_subregions(self):
         # Get all the subregions
         classes = (v for k, v in registry.get_subregions('DE').items())
         classes = list(classes)
         for klass in GERMANY_REGION_CLASSES:
             self.assertIn(klass, classes)
 
-    def test_switzerland_subregion(self):
+    def test_switzerland_subregions(self):
         # Get all the subregions
         classes = (v for k, v in registry.get_subregions('CH').items())
         classes = list(classes)
         for klass in SWITZERLAND_REGION_CLASSES:
             self.assertIn(klass, classes)
 
+    def test_spain_subregions(self):
+        # Get all the subregions
+        classes = (v for k, v in registry.get_subregions('ES').items())
+        classes = list(classes)
+        for klass in SPAIN_REGION_CLASSES:
+            self.assertIn(klass, classes)
+
     def test_slovenia_code(self):
         # Source: https://github.com/peopledoc/workalendar/pull/291
         self.assertEqual(registry.region_registry['SI'], Slovenia)