示例#1
0
    def testRenderNone(self):
        widget = ExceptionDateInput()
        out = widget.render('xdate', None, {'id': "id_xdate"})
        lines = [line for line in out.split("\n") if line]
        self.assertHTMLEqual(
            lines[0], """
<input type="text" name="xdate" id="id_xdate" autocomplete="{0.newDate}">""".
            format(self))
        self.assertIn('<script>initExceptionDateChooser("id_xdate", null, ',
                      lines[1])
        self.assertIn('"dayOfWeekStart": 0', lines[1])
        self.assertIn('"format": "Y-m-d"', lines[1])
        self.assertIn('</script>', lines[1])
示例#2
0
 def testValidDates(self):
     widget = ExceptionDateInput()
     widget.overrides_repeat = Recurrence(dtstart=dt.date(2009, 1, 1),
                                          freq=MONTHLY,
                                          byweekday=MO(1))
     self.assertEqual(widget.valid_dates(), [
         "20180903", "20181001", "20181105", "20181203", "20190107",
         "20190204", "20190304", "20190401", "20190506", "20190603",
         "20190701", "20190805", "20190902", "20191007", "20191104",
         "20191202", "20200106", "20200203", "20200302", "20200406",
         "20200504", "20200601", "20200706", "20200803", "20200907",
         "20201005"
     ])
示例#3
0
 def testMedia(self):
     widget = ExceptionDateInput()
     self.assertEqual(widget.media._css,
                      {'all': ["/static/joyous/css/recurrence_admin.css"]})
     self.assertEqual(widget.media._js,
                      ["/static/joyous/js/recurrence_admin.js"])
示例#4
0
 def testNullValue(self):
     widget = ExceptionDateInput()
     self.assertEqual(widget.value_from_datadict({}, {}, 'xdate'), None)