|
@@ -590,6 +590,19 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
|
|
|
'<input type="file" name="test">',
|
|
|
)
|
|
|
|
|
|
+ def test_render_with_attrs_id(self):
|
|
|
+ storage_url = default_storage.url("")
|
|
|
+ w = widgets.AdminFileWidget()
|
|
|
+ self.assertHTMLEqual(
|
|
|
+ w.render("test", self.album.cover_art, attrs={"id": "test_id"}),
|
|
|
+ f'<p class="file-upload">Currently: <a href="{storage_url}albums/'
|
|
|
+ r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a> '
|
|
|
+ '<span class="clearable-file-input">'
|
|
|
+ '<input type="checkbox" name="test-clear" id="test-clear_id"> '
|
|
|
+ '<label for="test-clear_id">Clear</label></span><br>'
|
|
|
+ 'Change: <input type="file" name="test" id="test_id"></p>',
|
|
|
+ )
|
|
|
+
|
|
|
def test_render_required(self):
|
|
|
widget = widgets.AdminFileWidget()
|
|
|
widget.is_required = True
|
|
@@ -618,6 +631,20 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
|
|
|
},
|
|
|
)
|
|
|
|
|
|
+ def test_render_checked(self):
|
|
|
+ storage_url = default_storage.url("")
|
|
|
+ widget = widgets.AdminFileWidget()
|
|
|
+ widget.checked = True
|
|
|
+ self.assertHTMLEqual(
|
|
|
+ widget.render("test", self.album.cover_art),
|
|
|
+ f'<p class="file-upload">Currently: <a href="{storage_url}albums/'
|
|
|
+ r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a> '
|
|
|
+ '<span class="clearable-file-input">'
|
|
|
+ '<input type="checkbox" name="test-clear" id="test-clear_id" checked>'
|
|
|
+ '<label for="test-clear_id">Clear</label></span><br>'
|
|
|
+ 'Change: <input type="file" name="test" checked></p>',
|
|
|
+ )
|
|
|
+
|
|
|
def test_readonly_fields(self):
|
|
|
"""
|
|
|
File widgets should render as a link when they're marked "read only."
|