1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Remove CONNECTION_STATUS_CONNECTED and CONNECTION_STATUS_PLANNED constants

This commit is contained in:
Jeremy Stretch
2020-02-24 14:14:58 -05:00
parent f7b620c6a2
commit 4d1749cc71
3 changed files with 8 additions and 12 deletions

View File

@ -61,13 +61,10 @@ POWERFEED_MAX_UTILIZATION_DEFAULT = 80 # Percentage
# Cabling and connections # Cabling and connections
# #
# TODO: Replace with CableStatusChoices?
# Console/power/interface connection statuses # Console/power/interface connection statuses
CONNECTION_STATUS_PLANNED = False
CONNECTION_STATUS_CONNECTED = True
CONNECTION_STATUS_CHOICES = [ CONNECTION_STATUS_CHOICES = [
[CONNECTION_STATUS_PLANNED, 'Planned'], [False, 'Not Connected'],
[CONNECTION_STATUS_CONNECTED, 'Connected'], [True, 'Connected'],
] ]
# Cable endpoint types # Cable endpoint types

View File

@ -2118,13 +2118,13 @@ class Cable(ChangeLoggedModel):
# Determine overall path status (connected or planned) # Determine overall path status (connected or planned)
if self.status == CableStatusChoices.STATUS_CONNECTED: if self.status == CableStatusChoices.STATUS_CONNECTED:
path_status = CONNECTION_STATUS_CONNECTED path_status = True
for segment in a_path[1:] + b_path[1:]: for segment in a_path[1:] + b_path[1:]:
if segment[1] is None or segment[1].status != CableStatusChoices.STATUS_CONNECTED: if segment[1] is None or segment[1].status != CableStatusChoices.STATUS_CONNECTED:
path_status = CONNECTION_STATUS_PLANNED path_status = False
break break
else: else:
path_status = CONNECTION_STATUS_PLANNED path_status = False
a_endpoint = a_path[-1][2] a_endpoint = a_path[-1][2]
b_endpoint = b_path[-1][2] b_endpoint = b_path[-1][2]

View File

@ -2,7 +2,6 @@ from django.core.exceptions import ValidationError
from django.test import TestCase from django.test import TestCase
from dcim.choices import * from dcim.choices import *
from dcim.constants import CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_PLANNED
from dcim.models import * from dcim.models import *
from tenancy.models import Tenant from tenancy.models import Tenant
@ -522,14 +521,14 @@ class CablePathTestCase(TestCase):
cable3.save() cable3.save()
interface1 = Interface.objects.get(pk=self.interface1.pk) interface1 = Interface.objects.get(pk=self.interface1.pk)
self.assertEqual(interface1.connected_endpoint, self.interface2) self.assertEqual(interface1.connected_endpoint, self.interface2)
self.assertEqual(interface1.connection_status, CONNECTION_STATUS_PLANNED) self.assertFalse(interface1.connection_status)
# Switch third segment from planned to connected # Switch third segment from planned to connected
cable3.status = CableStatusChoices.STATUS_CONNECTED cable3.status = CableStatusChoices.STATUS_CONNECTED
cable3.save() cable3.save()
interface1 = Interface.objects.get(pk=self.interface1.pk) interface1 = Interface.objects.get(pk=self.interface1.pk)
self.assertEqual(interface1.connected_endpoint, self.interface2) self.assertEqual(interface1.connected_endpoint, self.interface2)
self.assertEqual(interface1.connection_status, CONNECTION_STATUS_CONNECTED) self.assertTrue(interface1.connection_status)
def test_path_teardown(self): def test_path_teardown(self):
@ -542,7 +541,7 @@ class CablePathTestCase(TestCase):
cable3.save() cable3.save()
interface1 = Interface.objects.get(pk=self.interface1.pk) interface1 = Interface.objects.get(pk=self.interface1.pk)
self.assertEqual(interface1.connected_endpoint, self.interface2) self.assertEqual(interface1.connected_endpoint, self.interface2)
self.assertEqual(interface1.connection_status, CONNECTION_STATUS_CONNECTED) self.assertTrue(interface1.connection_status)
# Remove a cable # Remove a cable
cable2.delete() cable2.delete()