From fc534cef8c891d1fd4b63046d1c50664ed84b471 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 30 Nov 2023 10:56:10 +0100 Subject: [PATCH] Fix related names in PDU widget --- python/nav/web/navlets/forms.py | 4 ++-- tests/integration/widget_test.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/python/nav/web/navlets/forms.py b/python/nav/web/navlets/forms.py index 66cc1bd828..ee8cb3ac76 100644 --- a/python/nav/web/navlets/forms.py +++ b/python/nav/web/navlets/forms.py @@ -80,7 +80,7 @@ def __init__(self, *args, **kwargs): self.fields['room_id'].choices = [('', '----------')] + [ (r.pk, str(r)) for r in Room.objects.filter( - netbox__category='POWER', - netbox__sensors__internal_name__startswith='rPDULoadStatusLoad', + netboxes__category='POWER', + netboxes__sensors__internal_name__startswith='rPDULoadStatusLoad', ).distinct('id') ] diff --git a/tests/integration/widget_test.py b/tests/integration/widget_test.py index a1b65efc94..05e473db4e 100644 --- a/tests/integration/widget_test.py +++ b/tests/integration/widget_test.py @@ -5,7 +5,7 @@ from nav.web.navlets.roomstatus import RoomStatus from nav.web.navlets.feedreader import FeedReaderNavlet from nav.models.event import AlertHistory, AlertHistoryMessage -from nav.models.profiles import AccountNavlet +from nav.models.profiles import AccountDashboard, AccountNavlet from nav.models.fields import INFINITY import pytest @@ -39,6 +39,20 @@ def test_get_navlet_should_return_200(client, admin_navlet): assert response.status_code == 200 +def test_get_pdu_navlet_in_edit_mode_should_return_200(client, admin_account): + """Tests a GET request against the pdu navlet in edit mode""" + pdu_navlet = AccountNavlet.objects.create( + navlet="nav.web.navlets.pdu.PduWidget", + account=admin_account, + ) + url = reverse('get-user-navlet', kwargs={'navlet_id': pdu_navlet.id}) + "?mode=EDIT" + print( + "Testing admin navlet instance of {!r} at {!r}".format(pdu_navlet.navlet, url) + ) + response = client.get(url) + assert response.status_code == 200 + + # # Fixtures #