Skip to content

Commit

Permalink
Updated failure msgs and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitthalmagadum committed Feb 6, 2025
1 parent 7d0ce0a commit c14222f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
9 changes: 4 additions & 5 deletions anta/input_models/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ def __str__(self) -> str:
Examples
--------
Host 10.1.1.1, src: 10.2.2.2, vrf: mgmt, size: 100B, repeat: 2
Host: 10.1.1.1 Source: 10.2.2.2 VRF: mgmt
"""
df_status = ", df-bit: enabled" if self.df_bit else ""
return f"Host {self.destination}, src: {self.source}, vrf: {self.vrf}, size: {self.size}B, repeat: {self.repeat}{df_status}"
return f"Host: {self.destination} Source: {self.source} VRF: {self.vrf}"


class LLDPNeighbor(BaseModel):
Expand All @@ -59,10 +58,10 @@ def __str__(self) -> str:
Examples
--------
Port: Ethernet1, Neighbor: DC1-SPINE2, Neighbor Port: Ethernet2
Port: Ethernet1 Neighbor: DC1-SPINE2 Neighbor Port: Ethernet2
"""
return f"Port: {self.port}, Neighbor: {self.neighbor_device}, Neighbor Port: {self.neighbor_port}"
return f"Port: {self.port} Neighbor: {self.neighbor_device} Neighbor Port: {self.neighbor_port}"


class Neighbor(LLDPNeighbor): # pragma: no cover
Expand Down
22 changes: 11 additions & 11 deletions tests/units/anta_tests/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
],
},
],
"expected": {"result": "failure", "messages": ["Host 10.0.0.11, src: 10.0.0.5, vrf: default, size: 100B, repeat: 2 - Unreachable"]},
"expected": {"result": "failure", "messages": ["Host: 10.0.0.11 Source: 10.0.0.5 VRF: default - Unreachable"]},
},
{
"name": "failure-ipv6",
Expand All @@ -210,7 +210,7 @@
},
],
"inputs": {"hosts": [{"destination": "fd12:3456:789a:1::2", "source": "fd12:3456:789a:1::1"}]},
"expected": {"result": "failure", "messages": ["Host fd12:3456:789a:1::2 (src: fd12:3456:789a:1::1, vrf: default, size: 100B, repeat: 2) - Unreachable"]},
"expected": {"result": "failure", "messages": ["Host: fd12:3456:789a:1::2 Source: fd12:3456:789a:1::1 VRF: default - Unreachable"]},
},
{
"name": "failure-interface",
Expand Down Expand Up @@ -244,7 +244,7 @@
],
},
],
"expected": {"result": "failure", "messages": ["Host 10.0.0.11, src: Management0, vrf: default, size: 100B, repeat: 2 - Unreachable"]},
"expected": {"result": "failure", "messages": ["Host: 10.0.0.11 Source: Management0 VRF: default - Unreachable"]},
},
{
"name": "failure-size",
Expand All @@ -266,7 +266,7 @@
],
},
],
"expected": {"result": "failure", "messages": ["Host 10.0.0.1, src: Management0, vrf: default, size: 1501B, repeat: 5, df-bit: enabled - Unreachable"]},
"expected": {"result": "failure", "messages": ["Host: 10.0.0.1 Source: Management0 VRF: default - Unreachable"]},
},
{
"name": "success",
Expand Down Expand Up @@ -387,7 +387,7 @@
{"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"},
],
},
"expected": {"result": "failure", "messages": ["Port: Ethernet2, Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1 - Port not found"]},
"expected": {"result": "failure", "messages": ["Port: Ethernet2 Neighbor: DC1-SPINE2 Neighbor Port: Ethernet1 - Port not found"]},
},
{
"name": "failure-no-neighbor",
Expand Down Expand Up @@ -420,7 +420,7 @@
{"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"},
],
},
"expected": {"result": "failure", "messages": ["Port: Ethernet2, Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1 - No LLDP neighbors"]},
"expected": {"result": "failure", "messages": ["Port: Ethernet2 Neighbor: DC1-SPINE2 Neighbor Port: Ethernet1 - No LLDP neighbors"]},
},
{
"name": "failure-wrong-neighbor",
Expand Down Expand Up @@ -469,7 +469,7 @@
},
"expected": {
"result": "failure",
"messages": ["Port: Ethernet2, Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1 - Wrong LLDP neighbors: DC1-SPINE2/Ethernet2"],
"messages": ["Port: Ethernet2 Neighbor: DC1-SPINE2 Neighbor Port: Ethernet1 - Wrong LLDP neighbors: DC1-SPINE2/Ethernet2"],
},
},
{
Expand Down Expand Up @@ -507,9 +507,9 @@
"expected": {
"result": "failure",
"messages": [
"Port: Ethernet1, Neighbor: DC1-SPINE1, Neighbor Port: Ethernet1 - Wrong LLDP neighbors: DC1-SPINE1/Ethernet2",
"Port: Ethernet2, Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1 - No LLDP neighbors",
"Port: Ethernet3, Neighbor: DC1-SPINE3, Neighbor Port: Ethernet1 - Port not found",
"Port: Ethernet1 Neighbor: DC1-SPINE1 Neighbor Port: Ethernet1 - Wrong LLDP neighbors: DC1-SPINE1/Ethernet2",
"Port: Ethernet2 Neighbor: DC1-SPINE2 Neighbor Port: Ethernet1 - No LLDP neighbors",
"Port: Ethernet3 Neighbor: DC1-SPINE3 Neighbor Port: Ethernet1 - Port not found",
],
},
},
Expand Down Expand Up @@ -555,7 +555,7 @@
},
"expected": {
"result": "failure",
"messages": ["Port: Ethernet1, Neighbor: DC1-SPINE3, Neighbor Port: Ethernet1 - Wrong LLDP neighbors: DC1-SPINE1/Ethernet1, DC1-SPINE2/Ethernet1"],
"messages": ["Port: Ethernet1 Neighbor: DC1-SPINE3 Neighbor Port: Ethernet1 - Wrong LLDP neighbors: DC1-SPINE1/Ethernet1, DC1-SPINE2/Ethernet1"],
},
},
]

0 comments on commit c14222f

Please sign in to comment.