From 02f921f7a73e050eeea20c3b606b29565c616ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Leichtfu=C3=9F?= Date: Sat, 5 Sep 2020 12:57:22 +0200 Subject: [PATCH] added a simple test to check if the dropdown widgets has been rendered --- tests/testapp/tests/test_filters.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/testapp/tests/test_filters.py b/tests/testapp/tests/test_filters.py index bf07a2f..54a5de8 100644 --- a/tests/testapp/tests/test_filters.py +++ b/tests/testapp/tests/test_filters.py @@ -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'))