Exemplo n.º 1
0
    def test_yearly(self):
        correct = u"each August 15 of the year starting at 12:00 AM August 15, 2011 ten times"
        testrr = rrule_eq(YEARLY, dtstart=datetime(2011, 8, 15), count=10)
        hr = human_rrule(testrr)
        self.assertEqual(hr.get_description(), correct)

        correct = u"each Tuesday of the year starting at 12:00 AM August 16, 2011 ten times"
        testrr = rrule_eq(YEARLY, dtstart=datetime(2011, 8, 15), count=10, byweekday=TU)
        hr = human_rrule(testrr)
        self.assertEqual(hr.get_description(), correct)
Exemplo n.º 2
0
 def test_secondly(self):
     correct = u"each second starting at 00:00:00 AM August 15, 2011 ten times"
     testrr = rrule_eq(SECONDLY, dtstart=datetime(2011, 8, 15), count=10)
     hr = human_rrule(testrr)
     self.assertEqual(hr.get_description(time_format="%H:%M:%S %p"), correct)
     
     correct = "each second of the twenty first day of the month starting at 00:00:00 AM August 21, 2011 ten times"
     testrr = rrule_eq(SECONDLY, dtstart=datetime(2011, 8, 15), count=10, bymonthday=21)
     hr = human_rrule(testrr)
     self.assertEqual(hr.get_description(time_format="%H:%M:%S %p"), correct)
Exemplo n.º 3
0
    def test_monthly(self):
        correct = u"each third Friday of the month starting at 12:01 AM August 19, 2011 ten times"
        testrr = rrule_eq(MONTHLY, byweekday=FR(3), dtstart=datetime(2011, 8, 15, 0, 1), count=10)
        hr = human_rrule(testrr)
        self.assertEqual(hr.get_description(), correct)

        correct = u"every other first Sunday of the month starting at 09:00 PM October 02, 2011 until 09:00 PM August 05, 2012"
        testrr = rrule_eq(MONTHLY, interval=2, byweekday=SU(1), dtstart=datetime(2011, 8, 15, 21, 0, 0), until=datetime(2012, 8, 15))
        hr = human_rrule(testrr)
        self.assertEqual(hr.get_description(), correct)

        correct = u"every other first Sunday of the month starting at 09:00 PM 10/02/2011 until 09:00 PM 08/05/2012"
        self.assertEqual(hr.get_description(date_format="%m/%d/%Y"), correct)

        correct = u"every other first Sunday of the month starting at 21:00 October 02, 2011 until 21:00 August 05, 2012"
        self.assertEqual(hr.get_description(time_format="%H:%M"), correct)
Exemplo n.º 4
0
 def test_weekly(self):
     correct = u"each Monday of the week starting at 12:00 AM August 15, 2011 ten times"
     testrr = rrule_eq(WEEKLY, dtstart=datetime(2011, 8, 15), count=10)
     hr = human_rrule(testrr)
     self.assertEqual(hr.get_description(), correct)
Exemplo n.º 5
0
 def test_hourly(self):
     correct = u"each hour starting at 00:00:00 AM August 15, 2011 ten times"
     testrr = rrule_eq(HOURLY, dtstart=datetime(2011, 8, 15), count=10)
     hr = human_rrule(testrr)
     self.assertEqual(hr.get_description(time_format="%H:%M:%S %p"), correct)        
Exemplo n.º 6
0
 def test_invalid_freq(self):    
     testrr = rrule_eq("a", byweekday=MO, dtstart=datetime(2011, 8, 15), until=datetime(2012, 8, 15))
     self.assertRaises(ValueError, human_rrule, rrule=testrr)
 
     testrr = rrule_eq(None, byweekday=MO, dtstart=datetime(2011, 8, 15), until=datetime(2012, 8, 15))
     self.assertRaises(ValueError, human_rrule, rrule=testrr)