From 277373ba8954105212125a0f2a67b423f1cf883e Mon Sep 17 00:00:00 2001 From: DanielMowitz Date: Wed, 21 Apr 2021 22:39:51 +0200 Subject: [PATCH] Added tests for single and multiday holidays. --- test/calendar.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/calendar.t b/test/calendar.t index 552073b31..98949f52f 100755 --- a/test/calendar.t +++ b/test/calendar.t @@ -29,17 +29,27 @@ import sys import os import unittest +from datetime import datetime, timedelta # Ensure python finds the local simpletap module sys.path.append(os.path.dirname(os.path.abspath(__file__))) from basetest import Task, TestCase +def timestamp_in_holiday_format(time): + return time.strftime("%Y%m%d") + class TestCalendarCommandLine(TestCase): def setUp(self): """Executed before each test in the class""" self.t = Task() + tomorrow = datetime.now() + timedelta(days=1) + next_month = datetime.now() + timedelta(days=32) + + self.tomorrow = timestamp_in_holiday_format(tomorrow) + self.next_month = timestamp_in_holiday_format(next_month) + def test_basic_command(self): """Verify 'calendar' does not fail""" code, out, err = self.t("calendar") @@ -77,6 +87,16 @@ class TestCalendarCommandLine(TestCase): code, out, err = self.t("calendar rc.calendar.holidays:full") self.assertIn("Date Holiday", out) + def test_basic_command_single_holiday(self): + """Verify 'calendar rc.holiday.test.name:donkeyday rc.holiday.test.date:[tomorrws date] rc.calendar.holidays:full' does not fail""" + code, out, err = self.t("calendar rc.holiday.test.name:donkeyday rc.holliday.test.date:{0} rc.calendar.holidays:full".format(self.tomorrow)) + self.assertRegex(out, "Date +Holiday") + + def test_basic_command_multiday_holiday(self): + """Verify 'calendar rc.holiday.test.name:donkeyday rc.holiday.test.start:[tomorrws date] rc.holiday.test.end:[date a month later] rc.calendar.holidays:full' does not fail""" + code, out, err = self.t("calendar rc.holiday.test.name:donkeyday rc.holiday.test.start:{0} rc.holiday.test.end:{1} rc.calendar.holidays:full".format(self.tomorrow, self.next_month)) + self.assertRegex(out, "Date +Holiday") + def test_y_argument(self): """Verify 'calendar y' does not fail""" code, out, err = self.t("calendar y")