From cf39ca34062fd291ea98a14a41523a89955e8f04 Mon Sep 17 00:00:00 2001 From: Adrien Di Mascio Date: Thu, 31 Jan 2008 18:04:11 +0100 Subject: little function that adds a number of days worked to a date --- test/unittest_date.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/unittest_date.py b/test/unittest_date.py index 545b1b7..7d7ad18 100644 --- a/test/unittest_date.py +++ b/test/unittest_date.py @@ -8,10 +8,10 @@ from logilab.common.date import date_range try: from mx.DateTime import Date, RelativeDate - from logilab.common.date import endOfMonth + from logilab.common.date import endOfMonth, add_days_worked except ImportError: from datetime import date as Date - endOfMonth = None + endOfMonth = add_days_worked = None class DateTC(TestCase): @@ -35,6 +35,20 @@ class DateTC(TestCase): expected = [Date(2000,11,30), Date(2000,12,31), Date(2001,1,31)] self.assertListEquals(r, expected) + def test_add_days_worked(self): + if add_days_worked is None: + self.skip('mx.DateTime is not installed') + add = add_days_worked + # normal + self.assertEquals(add(Date(2008, 1, 3), 1), Date(2008, 1, 4)) + # skip week-end + self.assertEquals(add(Date(2008, 1, 3), 2), Date(2008, 1, 7)) + # skip 2 week-ends + self.assertEquals(add(Date(2008, 1, 3), 8), Date(2008, 1, 15)) + # skip holiday + week-end + self.assertEquals(add(Date(2008, 4, 30), 2), Date(2008, 5, 4)) + + if __name__ == '__main__': unittest_main() -- cgit v1.2.1