Skip to content

Commit

Permalink
Extend filterset/model tests to cover PowerOutlet.status
Browse files Browse the repository at this point in the history
  • Loading branch information
jnovinger committed Feb 26, 2025
1 parent 8efcbdd commit 2dcf2d2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions netbox/dcim/tests/test_filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3684,6 +3684,7 @@ def setUpTestData(cls):
feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A,
description='First',
color='ff0000',
status=PowerOutletStatusChoices.STATUS_ENABLED,
),
PowerOutlet(
device=devices[1],
Expand All @@ -3693,6 +3694,7 @@ def setUpTestData(cls):
feed_leg=PowerOutletFeedLegChoices.FEED_LEG_B,
description='Second',
color='00ff00',
status=PowerOutletStatusChoices.STATUS_DISABLED,
),
PowerOutlet(
device=devices[2],
Expand All @@ -3702,6 +3704,7 @@ def setUpTestData(cls):
feed_leg=PowerOutletFeedLegChoices.FEED_LEG_C,
description='Third',
color='0000ff',
status=PowerOutletStatusChoices.STATUS_FAULTY,
),
)
PowerOutlet.objects.bulk_create(power_outlets)
Expand Down Expand Up @@ -3796,6 +3799,23 @@ def test_connected(self):
params = {'connected': False}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

def test_status(self):
params = {'status': [PowerOutletStatusChoices.STATUS_ENABLED]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

params = {'status': [PowerOutletStatusChoices.STATUS_DISABLED]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

params = {'status': [PowerOutletStatusChoices.STATUS_FAULTY]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

params = {'status': [
PowerOutletStatusChoices.STATUS_ENABLED,
PowerOutletStatusChoices.STATUS_DISABLED,
PowerOutletStatusChoices.STATUS_FAULTY,
]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3)


class InterfaceTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFilterSetTests):
queryset = Interface.objects.all()
Expand Down
3 changes: 2 additions & 1 deletion netbox/dcim/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ def test_device_creation(self):
device=device,
name='Power Outlet 1',
power_port=powerport,
feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A
feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A,
status=PowerOutletStatusChoices.STATUS_ENABLED,
)
self.assertEqual(poweroutlet.cf['cf1'], 'foo')

Expand Down

0 comments on commit 2dcf2d2

Please sign in to comment.