mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
Clean up tests
This commit is contained in:
parent
4ae7e2f9a8
commit
58ca48987b
@ -40,7 +40,6 @@ class CablePathTestCase(TestCase):
|
|||||||
Return a given cable path
|
Return a given cable path
|
||||||
|
|
||||||
:param nodes: Iterable of steps, with each step being either a single node or a list of nodes
|
:param nodes: Iterable of steps, with each step being either a single node or a list of nodes
|
||||||
:param is_active: Boolean indicating whether the end-to-end path is complete and active (optional)
|
|
||||||
|
|
||||||
:return: The matching CablePath (if any)
|
:return: The matching CablePath (if any)
|
||||||
"""
|
"""
|
||||||
@ -54,31 +53,24 @@ class CablePathTestCase(TestCase):
|
|||||||
|
|
||||||
def assertPathExists(self, nodes, **kwargs):
|
def assertPathExists(self, nodes, **kwargs):
|
||||||
"""
|
"""
|
||||||
Assert that a CablePath from origin to destination with a specific intermediate path exists.
|
Assert that a CablePath from origin to destination with a specific intermediate path exists. Returns the
|
||||||
|
first matching CablePath, if found.
|
||||||
|
|
||||||
:param nodes: Iterable of steps, with each step being either a single node or a list of nodes
|
:param nodes: Iterable of steps, with each step being either a single node or a list of nodes
|
||||||
:param is_active: Boolean indicating whether the end-to-end path is complete and active (optional)
|
|
||||||
|
|
||||||
:return: The matching CablePath (if any)
|
|
||||||
"""
|
"""
|
||||||
cablepath = self._get_cablepath(nodes, **kwargs)
|
cablepath = self._get_cablepath(nodes, **kwargs)
|
||||||
self.assertIsNotNone(cablepath, msg='CablePath not found')
|
self.assertIsNotNone(cablepath, msg='CablePath not found')
|
||||||
|
|
||||||
return cablepath
|
return cablepath
|
||||||
|
|
||||||
def assertPathNotExists(self, nodes, **kwargs):
|
def assertPathDoesNotExist(self, nodes, **kwargs):
|
||||||
"""
|
"""
|
||||||
Assert that a CablePath from origin to destination with a specific intermediate path exists.
|
Assert that a specific CablePath does *not* exist.
|
||||||
|
|
||||||
:param nodes: Iterable of steps, with each step being either a single node or a list of nodes
|
:param nodes: Iterable of steps, with each step being either a single node or a list of nodes
|
||||||
:param is_active: Boolean indicating whether the end-to-end path is complete and active (optional)
|
|
||||||
|
|
||||||
:return: The matching CablePath (if any)
|
|
||||||
"""
|
"""
|
||||||
cablepath = self._get_cablepath(nodes, **kwargs)
|
cablepath = self._get_cablepath(nodes, **kwargs)
|
||||||
self.assertIsNone(cablepath, msg='CablePath not found')
|
self.assertIsNone(cablepath, msg='Unexpected CablePath found')
|
||||||
|
|
||||||
return cablepath
|
|
||||||
|
|
||||||
def assertPathIsSet(self, origin, cablepath, msg=None):
|
def assertPathIsSet(self, origin, cablepath, msg=None):
|
||||||
"""
|
"""
|
||||||
@ -2044,8 +2036,8 @@ class CablePathTestCase(TestCase):
|
|||||||
|
|
||||||
def test_401_non_symmetric_paths(self):
|
def test_401_non_symmetric_paths(self):
|
||||||
"""
|
"""
|
||||||
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] --C3-- -------------------------------------- [IF2]
|
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] -------------------------------------------C3-- [IF2]
|
||||||
[IF2] --C5-- [FP3] [RP3] --C4-- [RP4] [FP4] --C6-- [FP5] [RP5] --C7-- [RP6] [FP6] --C3---/
|
[IF2] --C5-- [FP3] [RP3] --C4-- [RP4] [FP4] --C6-- [FP5] [RP5] --C7-- [RP6] [FP6] --/
|
||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
@ -2165,7 +2157,7 @@ class CablePathTestCase(TestCase):
|
|||||||
def test_402_exclude_midspan_devices(self):
|
def test_402_exclude_midspan_devices(self):
|
||||||
"""
|
"""
|
||||||
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] --C3-- [IF2]
|
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] --C3-- [IF2]
|
||||||
[FP3] [RP3] --C4-- [RP4] [FP4] /
|
[FP3] [RP3] --C4-- [RP4] [FP4]
|
||||||
"""
|
"""
|
||||||
device = Device.objects.create(
|
device = Device.objects.create(
|
||||||
site=self.site,
|
site=self.site,
|
||||||
@ -2216,7 +2208,7 @@ class CablePathTestCase(TestCase):
|
|||||||
cable1.save()
|
cable1.save()
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
pass
|
pass
|
||||||
self.assertPathNotExists(
|
self.assertPathDoesNotExist(
|
||||||
(
|
(
|
||||||
interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
|
interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
|
||||||
(rearport2, rearport4), (frontport2, frontport4)
|
(rearport2, rearport4), (frontport2, frontport4)
|
||||||
@ -2236,7 +2228,7 @@ class CablePathTestCase(TestCase):
|
|||||||
cable3.save()
|
cable3.save()
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
pass
|
pass
|
||||||
self.assertPathNotExists(
|
self.assertPathDoesNotExist(
|
||||||
(
|
(
|
||||||
interface2, cable3, (frontport2, frontport4), (rearport2, rearport4), (cable2, cable4),
|
interface2, cable3, (frontport2, frontport4), (rearport2, rearport4), (cable2, cable4),
|
||||||
(rearport1, rearport3), (frontport1, frontport2), cable1, interface1
|
(rearport1, rearport3), (frontport1, frontport2), cable1, interface1
|
||||||
@ -2244,7 +2236,7 @@ class CablePathTestCase(TestCase):
|
|||||||
is_complete=True,
|
is_complete=True,
|
||||||
is_active=True
|
is_active=True
|
||||||
)
|
)
|
||||||
self.assertPathNotExists(
|
self.assertPathDoesNotExist(
|
||||||
(
|
(
|
||||||
interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
|
interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
|
||||||
(rearport2, rearport4), (frontport2, frontport4), cable3, interface2
|
(rearport2, rearport4), (frontport2, frontport4), cable3, interface2
|
||||||
|
Loading…
Reference in New Issue
Block a user