示例#1
0
    def test_render_js_init(self):
        widget = widgets.AdminTimeInput()

        html = widget.render("test", None, attrs={"id": "test-id"})

        self.assertInHTML(
            '<input type="text" name="test" autocomplete="off" id="test-id" />',
            html)

        # we should see the JS initialiser code:
        # initDateChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d"});
        # except that we can't predict the order of the config options
        self.assertIn('initTimeChooser("test\\u002Did", {', html)
        self.assertIn('"format": "H:i"', html)
示例#2
0
    def test_adapt_with_custom_format(self):
        widget = widgets.AdminTimeInput(format="%H:%M:%S")

        js_args = widgets.AdminTimeInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {"format": "H:i:s", "formatTime": "H:i:s"})
示例#3
0
    def test_adapt(self):
        widget = widgets.AdminTimeInput()

        js_args = widgets.AdminTimeInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {"format": "H:i", "formatTime": "H:i"})
    def test_adapt(self):
        widget = widgets.AdminTimeInput()

        js_args = widgets.AdminTimeInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {'format': 'H:i', 'formatTime': 'H:i'})