Ejemplo n.º 1
0
 def test_roundtrip(self):
     rrStr = "DTSTART:20151001\n" \
             "RRULE:FREQ=MONTHLY;WKST=SU;BYDAY=-1SU;BYMONTH=1,2,3,4,5,6,7,8,9,10,11"
     self.assertEqual(str(Recurrence(rrStr)), rrStr)
     rrStr = "DTSTART:20141001\n" \
             "RRULE:FREQ=MONTHLY;WKST=SU;UNTIL=20141001;BYMONTHDAY=1,-1"   # first&last
     self.assertEqual(str(Recurrence(rrStr)), rrStr)
Ejemplo n.º 2
0
 def test_str(self):
     rr = Recurrence(dtstart=datetime(2009, 1, 1),
                     freq=WEEKLY,
                     count=9,
                     byweekday=[MO, TU, WE, TH, FR])
     self.assertEqual(str(rr),
                     "DTSTART:20090101\n" \
                     "RRULE:FREQ=WEEKLY;WKST=SU;COUNT=9;BYDAY=MO,TU,WE,TH,FR")
     self.assertEqual(rr.count, rr.getCount())
     rr = Recurrence(dtstart=datetime(2011, 1, 1),
                     freq=DAILY,
                     interval=2,
                     until=datetime(2011, 1, 11))
     self.assertEqual(str(rr),
                     "DTSTART:20110101\n" \
                     "RRULE:FREQ=DAILY;INTERVAL=2;WKST=SU;UNTIL=20110111")
     rr = Recurrence(dtstart=datetime(2012, 1, 1),
                     freq=YEARLY,
                     bymonth=[1, 2],
                     byweekday=range(7),
                     until=datetime(2012, 1, 31))
     self.assertEqual(str(rr),
                     "DTSTART:20120101\n" \
                     "RRULE:FREQ=YEARLY;WKST=SU;UNTIL=20120131;" \
                     "BYDAY=MO,TU,WE,TH,FR,SA,SU;BYMONTH=1,2")
     rr = Recurrence(dtstart=datetime(2015, 10, 1),
                     freq=MONTHLY,
                     bymonth=range(1, 12),
                     byweekday=[(SU(-1))])
     self.assertEqual(str(rr),
                     "DTSTART:20151001\n" \
                     "RRULE:FREQ=MONTHLY;WKST=SU;BYDAY=-1SU;BYMONTH=1,2,3,4,5,6,7,8,9,10,11")
Ejemplo n.º 3
0
 def test_decompress_everyday_in_january(self):
     rr = Recurrence(dtstart=datetime(2014, 12, 1),
                     freq=YEARLY,
                     byweekday=[MO,TU,WE,TH,FR,SA,SU],
                     bymonth=[1])
     widget = RecurrenceWidget()
     self.assertEqual(widget.decompress(rr),
                      [datetime(2014, 12, 1), YEARLY, 1,
                       [], None, None,  #5
                       100, 200, 1])
Ejemplo n.º 4
0
 def test_decompress_weekdays(self):
     rr = Recurrence(dtstart=datetime(2009, 1, 1),
                     freq=WEEKLY,
                     count=9,
                     byweekday=[MO,TU,WE,TH,FR])
     widget = RecurrenceWidget()
     self.assertEqual(widget.decompress(rr),
                      [datetime(2009, 1, 1), WEEKLY, 1,
                       [0,1,2,3,4], 9, None,      #5
                       101, 200, None])
Ejemplo n.º 5
0
 def test_everyday_in_january_value(self):
     widget = RecurrenceWidget()
     data = {'repeat_0': '2014-12-1',
             'repeat_1': '0',
             'repeat_2': '1',
             'repeat_5': '',
             'repeat_6': '100',
             'repeat_7': '200',
             'repeat_8': '1'}
     rr = Recurrence(dtstart=datetime(2014, 12, 1),
                     freq=YEARLY,
                     byweekday=[MO,TU,WE,TH,FR,SA,SU],
                     bymonth=[1])
     self.assertEqual(str(widget.value_from_datadict(data, {}, 'repeat')),
                      str(rr))
Ejemplo n.º 6
0
 def test_weekdays_value(self):
     widget = RecurrenceWidget()
     data = {'repeat_0': '2009-01-01',
             'repeat_1': '2',
             'repeat_2': '1',
             'repeat_3': ['0','1','2','3','4'],
             'repeat_5': '2012-01-31',
             'repeat_6': '101',
             'repeat_7': '200',
             'repeat_8': '1'}
     rr = Recurrence(dtstart=datetime(2009, 1, 1),
                     freq=WEEKLY,
                     byweekday=[MO,TU,WE,TH,FR],
                     until=datetime(2012,1,31))
     self.assertEqual(str(widget.value_from_datadict(data, {}, 'repeat')),
                      str(rr))
Ejemplo n.º 7
0
 def test_parse(self):
     rr = Recurrence("DTSTART:20090101\n" \
                     "RRULE:FREQ=WEEKLY;WKST=SU;BYDAY=MO,TU,WE,TH,FR;COUNT=9")
     self.assertEqual(rr.dtstart, datetime(2009, 1, 1))
     self.assertEqual(rr.count, 9)
     self.assertCountEqual(rr.byweekday, [MO, TU, WE, TH, FR])