Skip to content

Commit

Permalink
Fix related names in PDU widget
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Nov 30, 2023
1 parent e0c73c7 commit fc534ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/nav/web/navlets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
]
16 changes: 15 additions & 1 deletion tests/integration/widget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
#
Expand Down

0 comments on commit fc534ce

Please sign in to comment.