Exemple #1
0
 def testSameDayOfMonthValue(self):
     widget = RecurrenceWidget()
     data = {
         'repeat_0': '2019-01-01',
         'repeat_1': '1',
         'repeat_2': '1',
         'repeat_5': '',
         'repeat_6': '101',
         'repeat_7': '200'
     }
     rr = Recurrence(dtstart=dt.date(2019, 1, 1), freq=MONTHLY)
     self.assertEqual(widget.value_from_datadict(data, {}, 'repeat'), rr)
Exemple #2
0
 def test135WednesdaysValue(self):
     widget = RecurrenceWidget()
     data = {
         'repeat_0': '2010-01-12',
         'repeat_1': '1',
         'repeat_2': '1',
         'repeat_6': '1',
         'repeat_7': '2',
         'repeat_8': '3',
         'repeat_9': '2',
         'repeat_10': '5',
         'repeat_11': '2'
     }
     rr = Recurrence(dtstart=dt.date(2010, 1, 12),
                     freq=MONTHLY,
                     byweekday=[WE(1), WE(3), WE(5)])
     self.assertEqual(widget.value_from_datadict(data, {}, 'repeat'), rr)
Exemple #3
0
 def testSameTuesdayValue(self):
     widget = RecurrenceWidget()
     data = {
         'repeat_0': '2010-01-12',
         'repeat_1': '1',
         'repeat_2': '1',
         'repeat_6': '101',
         'repeat_7': '1',
         'repeat_8': None,
         'repeat_9': None,
         'repeat_10': None,
         'repeat_11': None
     }
     rr = Recurrence(dtstart=dt.date(2010, 1, 12),
                     freq=MONTHLY,
                     byweekday=[TU(2)])
     self.assertEqual(widget.value_from_datadict(data, {}, 'repeat'), rr)
Exemple #4
0
 def testMonthOfTuesdaysValue(self):
     widget = RecurrenceWidget()
     data = {
         'repeat_0': '2010-01-05',
         'repeat_1': '1',
         'repeat_2': '1',
         'repeat_5': '2010-01-26',
         'repeat_6': '100',
         'repeat_7': '1',
         'repeat_8': None,
         'repeat_9': None,
         'repeat_10': None,
         'repeat_11': None
     }
     rr = Recurrence(dtstart=dt.date(2010, 1, 5),
                     freq=MONTHLY,
                     byweekday=[TU],
                     until=dt.date(2010, 1, 26))
     self.assertEqual(widget.value_from_datadict(data, {}, 'repeat'), rr)
Exemple #5
0
 def testDecompressNull(self):
     widget = RecurrenceWidget()
     self.assertEqual(
         widget.decompress(None),
         [
             None,
             None,
             1,
             [],
             None,
             None,  #5
             101,
             200,
             None,
             None,
             None,  #10
             None,
             []
         ])
Exemple #6
0
 def testEverydayInJanuaryValue(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': None,
         'repeat_9': None,
         'repeat_10': None,
         'repeat_11': None,
         'repeat_12': ['1']
     }
     rr = Recurrence(dtstart=dt.date(2014, 12, 1),
                     freq=YEARLY,
                     byweekday=[MO, TU, WE, TH, FR, SA, SU],
                     bymonth=[1])
     self.assertEqual(widget.value_from_datadict(data, {}, 'repeat'), rr)
Exemple #7
0
 def testGetContext(self):
     rr = Recurrence(dtstart=dt.date(2014, 12, 1),
                     freq=MONTHLY,
                     byweekday=[MO(1), MO(3), MO(5)])
     attrs = {'id': "id_repeat"}
     widget = RecurrenceWidget(attrs)
     context = widget.get_context("repeat", rr, None)
     self.assertEqual(list(context.keys()), ["widget"])
     ctx = context['widget']
     self.assertEqual(ctx['attrs'], attrs)
     self.assertEqual(ctx['name'], "repeat")
     self.assertIsInstance(ctx['subwidgets'], list)
     self.assertEqual(len(ctx['subwidgets']), 13)
     self.assertEqual(ctx['template_name'],
                      "joyous/widgets/recurrence_widget.html")
     when = "The first Monday, third Monday and fifth Monday of the month"
     self.assertEqual(ctx['value'], when)
     self.assertEqual(ctx['value_s'], when)
     self.assertEqual(
         ctx['value_r'], "DTSTART:20141201\n"
         "RRULE:FREQ=MONTHLY;WKST=SU;BYDAY=+1MO,+3MO,+5MO")
Exemple #8
0
 def testDecompressDayOfMonth(self):
     rr = Recurrence(dtstart=dt.date(2019, 1, 1),
                     freq=MONTHLY,
                     bymonthday=1)
     widget = RecurrenceWidget()
     self.assertEqual(
         widget.decompress(rr),
         [
             dt.date(2019, 1, 1),
             MONTHLY,
             1,
             [],
             None,
             None,  #5
             101,
             200,
             None,
             None,
             None,  #10
             None,
             []
         ])
Exemple #9
0
 def testWeekdaysValue(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': None,
         'repeat_9': None,
         'repeat_10': None,
         'repeat_11': None,
         'repeat_12': []
     }
     rr = Recurrence(dtstart=dt.date(2009, 1, 1),
                     freq=WEEKLY,
                     byweekday=[MO, TU, WE, TH, FR],
                     until=dt.date(2012, 1, 31))
     self.assertEqual(str(widget.value_from_datadict(data, {}, 'repeat')),
                      str(rr))
Exemple #10
0
 def testDecompressEverydayInJanuary(self):
     rr = Recurrence(dtstart=dt.date(2014, 12, 1),
                     freq=YEARLY,
                     byweekday=[MO, TU, WE, TH, FR, SA, SU],
                     bymonth=[1])
     widget = RecurrenceWidget()
     self.assertEqual(
         widget.decompress(rr),
         [
             dt.date(2014, 12, 1),
             YEARLY,
             1,
             [],
             None,
             None,  #5
             100,
             200,
             None,
             None,
             None,  #10
             None,
             [1]
         ])
Exemple #11
0
 def testDecompressWeekdays(self):
     rr = Recurrence(dtstart=dt.date(2009, 1, 1),
                     freq=WEEKLY,
                     count=9,
                     byweekday=[MO, TU, WE, TH, FR])
     widget = RecurrenceWidget()
     self.assertEqual(
         widget.decompress(rr),
         [
             dt.date(2009, 1, 1),
             WEEKLY,
             1,
             [0, 1, 2, 3, 4],
             9,
             None,  #5
             101,
             200,
             None,
             None,
             None,  #10
             None,
             []
         ])
Exemple #12
0
 def testMedia(self):
     widget = RecurrenceWidget()
     self.assertIn("/static/joyous/css/recurrence_admin.css",
                   widget.media._css['all'])
     self.assertIn("/static/joyous/js/recurrence_admin.js",
                   widget.media._js)
Exemple #13
0
 def testNullValue(self):
     widget = RecurrenceWidget()
     self.assertEqual(widget.value_from_datadict({}, {}, 'repeat'), None)
Exemple #14
0
 def testMedia(self):
     widget = RecurrenceWidget()
     self.assertEqual(widget.media._css,
                      {'all': ["/static/joyous/css/recurrence_admin.css"]})
     self.assertEqual(widget.media._js,
                      ["/static/joyous/js/recurrence_admin.js"])