def test_is_business_day(self):
     c2 = SimpleCalendar((date(2014, 12, 25), date(2014, 12, 26)))
     self.assertTrue(c2.is_business_day(date(2014, 12, 24)), "Wednesday 24 December 2014 is a business day.")
     self.assertFalse(c2.is_business_day(date(2014, 12, 25)), "Thursday 25 December 2014 is not a business day.")
     self.assertFalse(c2.is_business_day(date(2014, 12, 26)), "Friday 26 December 2014 is not a business day.")
     self.assertFalse(c2.is_business_day(date(2014, 12, 27)), "Saturday 27 December 2014 is not a business day.")
     self.assertFalse(c2.is_business_day(date(2014, 12, 28)), "Sunday 28 December 2014 is not a business day.")
     self.assertTrue(c2.is_business_day(date(2014, 12, 29)), "Monday 29 December 2014 is a business day.")
    def test_adjust(self):
        cal = SimpleCalendar((date(2015, 1, 1), date(2015, 4, 3), date(2015, 4, 6), date(2015, 5, 1), date(2015, 12, 25), date(2015, 12, 16)))

        jan_first = date(2015, 1, 1)
        jan_second = date(2015, 1, 2)
        
        # BusinessDayConvention.none
        self.assertEqual(jan_first, cal.adjust(jan_first, BusinessDayConvention.none), "No adjustment.")
        
        # BusinessDayConvention.following
        self.assertEqual(jan_second, cal.adjust(jan_first, BusinessDayConvention.following), "Adjusted to January 2.")
 def test_nearest_business_day(self):
     #              July 2015
     # Su Mo Tu We Th Fr Sa
     #           1  2  3  4
     #  5  6  7  8  9 10 11
     # 12 13 14 15 16 17 18
     # 19 20 21 22 23 24 25
     # 26 27 28 29 30 31
     cal = SimpleCalendar([date(2015, 7, 13)])
     self.assertEquals(date(2015, 7, 3), cal.nearest_business_day(date(2015, 7, 4)), "Saturday should roll to Friday")
     self.assertEquals(date(2015, 7, 6), cal.nearest_business_day(date(2015, 7, 5)), "Sunday should roll to Monday")
     self.assertEquals(date(2015, 7, 14), cal.nearest_business_day(date(2015, 7, 12), True), "Sunday should prefer to roll to Tuesday")
     self.assertEquals(date(2015, 7, 10), cal.nearest_business_day(date(2015, 7, 12), False), "Sunday should prefer to roll to Friday")
 def test_add_business_days(self):
     cal = SimpleCalendar((date(2015, 1, 1), date(2015, 4, 3), date(2015, 4, 6), date(2015, 5, 1), date(2015, 12, 25), date(2015, 12, 16)))
     # Forward
     self.assertEqual(date(2015, 1, 8), cal.add_business_days(date(2015, 1, 1), 5), "Should skip New Years Day.")
     self.assertEqual(date(2015, 1, 8), cal.add_business_days(date(2015, 1, 2), 4), "Nothing to skip.")
     self.assertEqual(date(2015, 1, 2), cal.add_business_days(date(2014, 12, 29), 3), "Nothing to skip.")
     # Back
     self.assertEqual(date(2014, 12, 31), cal.add_business_days(date(2015, 1, 8), -5), "Should skip New Years Day.")
     self.assertEqual(date(2015, 1, 2), cal.add_business_days(date(2015, 1, 8), -4), "Nothing to skip.")
     self.assertEqual(date(2014, 12, 29), cal.add_business_days(date(2015, 1, 2), -3), "Nothing to skip.")
 def test_is_holiday(self):
     c2 = SimpleCalendar((date(2014, 12, 25), date(2014, 12, 26)))
     self.assertTrue(c2.is_holiday(date(2014, 12, 25)), "Thursday 25 December 2014 is a holiday.")
     self.assertTrue(c2.is_holiday(date(2014, 12, 26)), "Friday 26 December 2014 is a holiday.")
     self.assertFalse(c2.is_holiday(date(2014, 12, 27)), "Saturday 27 December 2014 is not a holiday.")