mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Added tests for single and multiday holidays.
This commit is contained in:
parent
a16f3addc7
commit
277373ba89
1 changed files with 20 additions and 0 deletions
|
@ -29,17 +29,27 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
from datetime import datetime, timedelta
|
||||||
# Ensure python finds the local simpletap module
|
# Ensure python finds the local simpletap module
|
||||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
from basetest import Task, TestCase
|
from basetest import Task, TestCase
|
||||||
|
|
||||||
|
|
||||||
|
def timestamp_in_holiday_format(time):
|
||||||
|
return time.strftime("%Y%m%d")
|
||||||
|
|
||||||
class TestCalendarCommandLine(TestCase):
|
class TestCalendarCommandLine(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Executed before each test in the class"""
|
"""Executed before each test in the class"""
|
||||||
self.t = Task()
|
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):
|
def test_basic_command(self):
|
||||||
"""Verify 'calendar' does not fail"""
|
"""Verify 'calendar' does not fail"""
|
||||||
code, out, err = self.t("calendar")
|
code, out, err = self.t("calendar")
|
||||||
|
@ -77,6 +87,16 @@ class TestCalendarCommandLine(TestCase):
|
||||||
code, out, err = self.t("calendar rc.calendar.holidays:full")
|
code, out, err = self.t("calendar rc.calendar.holidays:full")
|
||||||
self.assertIn("Date Holiday", out)
|
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):
|
def test_y_argument(self):
|
||||||
"""Verify 'calendar y' does not fail"""
|
"""Verify 'calendar y' does not fail"""
|
||||||
code, out, err = self.t("calendar y")
|
code, out, err = self.t("calendar y")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue