Clean up tests

This commit is contained in:
Jeremy Stretch 2023-09-18 10:38:49 -04:00
parent 4ae7e2f9a8
commit 58ca48987b

View File

@ -40,7 +40,6 @@ class CablePathTestCase(TestCase):
Return a given cable path
: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)
"""
@ -54,31 +53,24 @@ class CablePathTestCase(TestCase):
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 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)
self.assertIsNotNone(cablepath, msg='CablePath not found')
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 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)
self.assertIsNone(cablepath, msg='CablePath not found')
return cablepath
self.assertIsNone(cablepath, msg='Unexpected CablePath found')
def assertPathIsSet(self, origin, cablepath, msg=None):
"""
@ -2044,8 +2036,8 @@ class CablePathTestCase(TestCase):
def test_401_non_symmetric_paths(self):
"""
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] --C3-- -------------------------------------- [IF2]
[IF2] --C5-- [FP3] [RP3] --C4-- [RP4] [FP4] --C6-- [FP5] [RP5] --C7-- [RP6] [FP6] --C3---/
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] -------------------------------------------C3-- [IF2]
[IF2] --C5-- [FP3] [RP3] --C4-- [RP4] [FP4] --C6-- [FP5] [RP5] --C7-- [RP6] [FP6] --/
"""
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
@ -2165,7 +2157,7 @@ class CablePathTestCase(TestCase):
def test_402_exclude_midspan_devices(self):
"""
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] --C3-- [IF2]
[FP3] [RP3] --C4-- [RP4] [FP4] /
[FP3] [RP3] --C4-- [RP4] [FP4]
"""
device = Device.objects.create(
site=self.site,
@ -2216,7 +2208,7 @@ class CablePathTestCase(TestCase):
cable1.save()
except AssertionError:
pass
self.assertPathNotExists(
self.assertPathDoesNotExist(
(
interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
(rearport2, rearport4), (frontport2, frontport4)
@ -2236,7 +2228,7 @@ class CablePathTestCase(TestCase):
cable3.save()
except AssertionError:
pass
self.assertPathNotExists(
self.assertPathDoesNotExist(
(
interface2, cable3, (frontport2, frontport4), (rearport2, rearport4), (cable2, cable4),
(rearport1, rearport3), (frontport1, frontport2), cable1, interface1
@ -2244,7 +2236,7 @@ class CablePathTestCase(TestCase):
is_complete=True,
is_active=True
)
self.assertPathNotExists(
self.assertPathDoesNotExist(
(
interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
(rearport2, rearport4), (frontport2, frontport4), cable3, interface2