Skip to content

Commit 82d30f0

Browse files
authored
[fix:tests] Fixed failing tests due to django-nested-admin
1 parent 7763d62 commit 82d30f0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

openwisp_monitoring/device/tests/test_admin.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,10 @@ def _get_inline_admin_heading(self, heading):
9999
This method helps us generate the appropriate HTML heading format
100100
based on the Django version being used.
101101
"""
102-
if django.VERSION < (5, 1) and heading != "Alert Settings":
102+
if django.VERSION < (5, 1) or heading in ["Alert Settings"]:
103103
return f"<h2>{heading}</h2>"
104104
heading_map = {
105105
"Checks": f"{Check._meta.app_label}-check-content_type-object_id-heading",
106-
"Alert Settings": f"{Metric._meta.app_label}-metric-content_type-object_id-heading",
107106
"WiFi Sessions": "wifisession_set-heading",
108107
"Configuration": "config-heading",
109108
"Map": "devicelocation-heading",
@@ -643,7 +642,14 @@ def _assert_alertsettings_inline_in_response(response):
643642
'<img src="/static/admin/img/icon-yes.svg" alt="True">',
644643
html=True,
645644
)
646-
self.assertContains(response, "<h2>Advanced options</h2>", html=True)
645+
# TODO: Remove when dropping support for Django 4.2
646+
self.assertContains(
647+
response,
648+
(
649+
'<h{heading_level} class="fieldset-heading">Advanced options</h{heading_level}>'
650+
).format(heading_level=2 if django.VERSION < (5, 1) else 4),
651+
html=True,
652+
)
647653
self.assertContains(
648654
response,
649655
"metric-content_type-object_id-0-alertsettings-0-is_active",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
openwisp-controller @ https://github.com/openwisp/openwisp-controller/tarball/1.2
22
influxdb~=5.3.2
3-
django-nested-admin~=4.1.1
3+
django-nested-admin~=4.1.3
44
python-dateutil>=2.7.0,<3.0.0

0 commit comments

Comments
 (0)