Repository: peopledoc/workalendar
Pull request #377 (2019-06-26 15:55:10)

add europe day for Luxembourg
Since this year there is a new national holiday in Luxembourg "Europe Day".

- [x] Tests with a significant number of years to be tested for your calendar.
- [x] Changelog amended with a mention describing your changes.



brunobord: Hi! Thanks a lot for this contribution, much appreciated!

However, if it's "since this year", I guess that this pull-request is wrong.

You may want to test that, prior to 2019, this Europe Day isn't a holiday, and in 2019 and beyond, this day was integrated into the holidays.
You may want to override the ``get_fixed_holidays`` method and test the value of the parameter "year" to correctly implement this.
sim0nx: > Hi! Thanks a lot for this contribution, much appreciated!
> 
> However, if it's "since this year", I guess that this pull-request is wrong.
> 
> You may want to test that, prior to 2019, this Europe Day isn't a holiday, and in 2019 and beyond, this day was integrated into the holidays.
> You may want to override the `get_fixed_holidays` method and test the value of the parameter "year" to correctly implement this.

Good point, oops! :-)
I fixed that.
brunobord: Looks excellent! I'll try to merge this and make a bugfix release as soon as I can, stay tuned!
sim0nx: > Looks excellent! I'll try to merge this and make a bugfix release as soon as I can, stay tuned!

Great! Appreciate it!

Patch:
diff --git a/Changelog.md b/Changelog.md
index fa0bea6..b0afafb 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -3,6 +3,7 @@
 ## master (unreleased)
 
 - Display missing lines in coverage report (#376).
+- Add "Europe Day" for Luxembourg (#377).
 
 ## v5.1.0 (2019-06-24)
 
diff --git a/workalendar/europe/luxembourg.py b/workalendar/europe/luxembourg.py
index f5e50e1..69834e2 100644
--- a/workalendar/europe/luxembourg.py
+++ b/workalendar/europe/luxembourg.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
+from datetime import date
 from workalendar.core import WesternCalendar, ChristianMixin
 from ..registry_tools import iso_register
 
@@ -19,3 +20,10 @@ class Luxembourg(WesternCalendar, ChristianMixin):
         (5, 1, "Labour Day"),
         (6, 23, "Luxembourg National Holiday"),
     )
+
+    def get_fixed_holidays(self, year):
+        days = super(Luxembourg, self).get_fixed_holidays(year)
+        if year > 2018:
+            days.append((date(year, 5, 9), "Europe Day"))
+
+        return days


Test patch:
diff --git a/workalendar/tests/test_europe.py b/workalendar/tests/test_europe.py
index 6dc73a6..250a42e 100644
--- a/workalendar/tests/test_europe.py
+++ b/workalendar/tests/test_europe.py
@@ -738,6 +738,13 @@ class LuxembourgTest(GenericCalendarTest):
         self.assertIn(date(2016, 12, 25), holidays)  # Christmas
         self.assertIn(date(2016, 12, 26), holidays)  # St. Stephen´s Day
 
+        self.assertNotIn(date(2016, 5, 9), holidays)  # Europe Day (>=2019)
+
+    def test_year_2019(self):
+        holidays = self.cal.holidays_set(2019)
+
+        self.assertIn(date(2019, 5, 9), holidays)   # Europe Day (>=2019)
+
 
 class NetherlandsTest(GenericCalendarTest):