added a simple test to check if the dropdown widgets has been rendered

django-5.0
Thomas Leichtfuß 2020-09-05 12:57:22 +02:00
parent 1427752d03
commit 02f921f7a7
1 changed files with 13 additions and 2 deletions

View File

@ -7,7 +7,7 @@ from django.urls import reverse
from ..management.commands.createtestdata import create_test_data
class ExportTest(TestCase):
class FilterTest(TestCase):
@classmethod
def setUpTestData(cls):
create_test_data()
@ -17,6 +17,17 @@ class ExportTest(TestCase):
self.client.force_login(self.admin)
self.url = reverse('admin:testapp_modela_changelist')
def test_01_load_changelist(self):
def test_01_dropdown_select(self):
resp = self.client.get(self.url)
self.assertEqual(resp.status_code, 200)
# the dropdown widget should have been loaded for dropdown_gt3
self.assertIn('dropdown-gt3_filter_select', resp.content.decode('utf8'))
# but not for dropdown_lte3
self.assertNotIn('dropdown-lte3_filter_select', resp.content.decode('utf8'))
# check other dropdown widgets
self.assertIn('multiselect-dropdown_select', resp.content.decode('utf8'))
self.assertIn('choices-dropdown_filter_select', resp.content.decode('utf8'))
self.assertIn('related-dropdown_filter_select', resp.content.decode('utf8'))
self.assertIn('multiselect-related-dropdown_select', resp.content.decode('utf8'))