Example #1
0
    def test_custom_file_widget(self):
        """
        ``ClearableFileInput`` respects its ``file_widget`` argument.

        """
        widget = ClearableFileInput(file_widget=ImageWidget())
        html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png'))
        self.assertTrue('<img' in html)
Example #2
0
    def test_custom_file_widget(self):
        """
        ``ClearableFileInput`` respects its ``file_widget`` argument.

        """
        widget = ClearableFileInput(file_widget=ImageWidget())
        html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png'))
        self.assertTrue('<img' in html)
Example #3
0
    def test_custom_file_widget(self):
        """
        ``ClearableFileInput`` respects its ``file_widget`` argument.

        """
        widget = ClearableFileInput(file_widget=ImageWidget())
        html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png'))
        self.assertTrue(html.startswith(
                '<input type="file" name="fieldname_0" value="tiny.png" />'
                '<br /><img src="/media/tiny'))
Example #4
0
    def test_custom_template(self):
        """
        ``ClearableFileInput`` respects its ``template`` argument.

        """
        widget = ClearableFileInput(template='Clear: %(checkbox)s %(input)s')
        html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png'))
        self.assertEqual(html,
                          'Clear: '
                          '<input type="checkbox" name="fieldname_1" /> '
                          '<input type="file" name="fieldname_0" />')
Example #5
0
    def test_custom_template(self):
        """
        ``ClearableFileInput`` respects its ``template`` argument.

        """
        widget = ClearableFileInput(template='Clear: %(checkbox)s %(input)s')
        html = widget.render('fieldname',
                             ImageFieldFile(None, ImageField(), 'tiny.png'))
        self.assertHTMLEqual(
            html, 'Clear: '
            '<input type="checkbox" name="fieldname_1" /> '
            '<input type="file" name="fieldname_0" />')
Example #6
0
    def test_render(self):
        """
        ``ClearableFileInput`` renders the file input and an unchecked
        clear checkbox.

        """
        widget = ClearableFileInput()
        html = widget.render('fieldname', 'tiny.png')
        self.assertHTMLEqual(
            html, '<input type="file" name="fieldname_0" />'
            ' Clear: '
            '<input type="checkbox" name="fieldname_1" />')
Example #7
0
    def test_render(self):
        """
        ``ClearableFileInput`` renders the file input and an unchecked
        clear checkbox.

        """
        widget = ClearableFileInput()
        html = widget.render('fieldname', 'tiny.png')
        self.assertEqual(html,
                          '<input type="file" name="fieldname_0" />'
                          ' Clear: '
                          '<input type="checkbox" name="fieldname_1" />')