Skip to content

Commit

Permalink
Reverting changes related to comma
Browse files Browse the repository at this point in the history
  • Loading branch information
vitthalmagadum committed Nov 28, 2024
1 parent 39d6af4 commit ba74697
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions anta/input_models/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def __str__(self) -> str:
Host 10.1.1.1 (src: 10.2.2.2 vrf: mgmt size: 100B repeat: 2)
"""
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})"
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})"


class LLDPNeighbor(BaseModel):
Expand All @@ -62,7 +62,7 @@ def __str__(self) -> str:
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
2 changes: 1 addition & 1 deletion anta/input_models/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def __str__(self) -> str:
--------
Server 10.0.0.1 (VRF: default Priority: 1)
"""
return f"Server {self.server_address} (VRF: {self.vrf} Priority: {self.priority})"
return f"Server {self.server_address} (VRF: {self.vrf}, Priority: {self.priority})"
2 changes: 1 addition & 1 deletion anta/input_models/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class NTPServer(BaseModel):

def __str__(self) -> str:
"""Representation of the NTPServer model."""
return f"{self.server_address} (Preferred: {self.preferred} Stratum: {self.stratum})"
return f"{self.server_address} (Preferred: {self.preferred}, Stratum: {self.stratum})"
4 changes: 2 additions & 2 deletions anta/tests/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ def test(self) -> None:
for info in lldp_neighbor_info
)
if not match_found:
failure_msg = [f"`{info['systemName']}/{info['neighborInterfaceInfo']['interfaceId_v2']}`" for info in lldp_neighbor_info]
self.result.is_failure(f"{neighbor} - Wrong LLDP neighbors: {' '.join(failure_msg)}")
failure_msg = [f"{info['systemName']}/{info['neighborInterfaceInfo']['interfaceId_v2']}" for info in lldp_neighbor_info]
self.result.is_failure(f"{neighbor} - Wrong LLDP neighbors: {', '.join(failure_msg)}")
6 changes: 3 additions & 3 deletions anta/tests/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ def test(self) -> None:
# If line protocol status is provided, prioritize checking against both status and line protocol status
if interface.line_protocol_status:
if interface.status != status or interface.line_protocol_status != proto:
actual_state = f"Expected: {interface.status}/{interface.line_protocol_status} Actual: {status}/{proto}"
actual_state = f"Expected: {interface.status}/{interface.line_protocol_status}, Actual: {status}/{proto}"
self.result.is_failure(f"{interface.name} - {actual_state}")

# If line protocol status is not provided and interface status is "up", expect both status and proto to be "up"
# If interface status is not "up", check only the interface status without considering line protocol status
elif interface.status == "up" and (status != "up" or proto != "up"):
self.result.is_failure(f"{interface.name} - Expected: up/up Actual: {status}/{proto}")
self.result.is_failure(f"{interface.name} - Expected: up/up, Actual: {status}/{proto}")
elif interface.status != status:
self.result.is_failure(f"{interface.name} - Expected: {interface.status} Actual: {status}")
self.result.is_failure(f"{interface.name} - Expected: {interface.status}, Actual: {status}")


class VerifyStormControlDrops(AntaTest):
Expand Down
4 changes: 2 additions & 2 deletions anta/tests/routing/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test(self) -> None:
inq = peer["peerTcpInfo"]["inputQueueLength"]
outq = peer["peerTcpInfo"]["outputQueueLength"]
if address_family.check_tcp_queues and (inq != 0 or outq != 0):
self.result.is_failure(f"{address_family} Peer: {peer['peerAddress']} - Session has non-empty message queues - InQ: {inq} OutQ: {outq}")
self.result.is_failure(f"{address_family} Peer: {peer['peerAddress']} - Session has non-empty message queues - InQ: {inq}, OutQ: {outq}")


class VerifyBGPSpecificPeers(AntaTest):
Expand Down Expand Up @@ -387,7 +387,7 @@ def test(self) -> None:
inq = peer_data["peerTcpInfo"]["inputQueueLength"]
outq = peer_data["peerTcpInfo"]["outputQueueLength"]
if address_family.check_tcp_queues and (inq != 0 or outq != 0):
self.result.is_failure(f"{address_family} Peer: {peer_ip} - Session has non-empty message queues - InQ: {inq} OutQ: {outq}")
self.result.is_failure(f"{address_family} Peer: {peer_ip} - Session has non-empty message queues - InQ: {inq}, OutQ: {outq}")


class VerifyBGPExchangedRoutes(AntaTest):
Expand Down
2 changes: 1 addition & 1 deletion anta/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ def test(self) -> None:
act_stratum = get_value(peers[matching_peer], "stratumLevel")

if act_condition != exp_condition or act_stratum != exp_stratum:
self.result.is_failure(f"{ntp_server} - Bad association - Condition: {act_condition} Stratum: {act_stratum}")
self.result.is_failure(f"{ntp_server} - Bad association - Condition: {act_condition}, Stratum: {act_stratum}")
2 changes: 1 addition & 1 deletion anta/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,4 @@ def format_data(data: dict[str, bool]) -> str:
>>> format_data({"advertised": True, "received": True, "enabled": True})
"Advertised: True Received: True Enabled: True"
"""
return " ".join(f"{k.capitalize()}: {v}" for k, v in data.items())
return ", ".join(f"{k.capitalize()}: {v}" for k, v in data.items())
24 changes: 12 additions & 12 deletions tests/units/anta_tests/routing/test_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,13 @@ def test_check_bgp_neighbor_capability(input_dict: dict[str, bool], expected: bo
"result": "failure",
"messages": [
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - Session state is not established - State: Idle",
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - AFI/SAFI state is not negotiated - Advertised: False Received: False Enabled: True",
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - AFI/SAFI state is not negotiated - Advertised: False, Received: False, Enabled: True",
"AFI: ipv4 SAFI: sr-te VRF: MGMT Peer: 10.100.0.12 - Session state is not established - State: Idle",
"AFI: ipv4 SAFI: sr-te VRF: MGMT Peer: 10.100.0.12 - AFI/SAFI state is not negotiated - Advertised: False Received: False Enabled: False",
"AFI: ipv4 SAFI: sr-te VRF: MGMT Peer: 10.100.0.12 - AFI/SAFI state is not negotiated - Advertised: False, Received: False, Enabled: False",
"AFI: path-selection Peer: 10.100.0.13 - Session state is not established - State: Idle",
"AFI: path-selection Peer: 10.100.0.13 - AFI/SAFI state is not negotiated - Advertised: True Received: False Enabled: False",
"AFI: path-selection Peer: 10.100.0.13 - AFI/SAFI state is not negotiated - Advertised: True, Received: False, Enabled: False",
"AFI: link-state Peer: 10.100.0.14 - Session state is not established - State: Idle",
"AFI: link-state Peer: 10.100.0.14 - AFI/SAFI state is not negotiated - Advertised: False Received: False Enabled: False",
"AFI: link-state Peer: 10.100.0.14 - AFI/SAFI state is not negotiated - Advertised: False, Received: False, Enabled: False",
],
},
},
Expand Down Expand Up @@ -688,13 +688,13 @@ def test_check_bgp_neighbor_capability(input_dict: dict[str, bool], expected: bo
"result": "failure",
"messages": [
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - Session state is not established - State: Idle",
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - Session has non-empty message queues - InQ: 2 OutQ: 4",
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - Session has non-empty message queues - InQ: 2, OutQ: 4",
"AFI: ipv4 SAFI: sr-te VRF: MGMT Peer: 10.100.0.12 - Session state is not established - State: Idle",
"AFI: ipv4 SAFI: sr-te VRF: MGMT Peer: 10.100.0.12 - Session has non-empty message queues - InQ: 5 OutQ: 1",
"AFI: ipv4 SAFI: sr-te VRF: MGMT Peer: 10.100.0.12 - Session has non-empty message queues - InQ: 5, OutQ: 1",
"AFI: path-selection Peer: 10.100.0.13 - Session state is not established - State: Idle",
"AFI: path-selection Peer: 10.100.0.13 - Session has non-empty message queues - InQ: 1 OutQ: 1",
"AFI: path-selection Peer: 10.100.0.13 - Session has non-empty message queues - InQ: 1, OutQ: 1",
"AFI: link-state Peer: 10.100.0.14 - Session state is not established - State: Idle",
"AFI: link-state Peer: 10.100.0.14 - Session has non-empty message queues - InQ: 3 OutQ: 2",
"AFI: link-state Peer: 10.100.0.14 - Session has non-empty message queues - InQ: 3, OutQ: 2",
],
},
},
Expand Down Expand Up @@ -892,8 +892,8 @@ def test_check_bgp_neighbor_capability(input_dict: dict[str, bool], expected: bo
"expected": {
"result": "failure",
"messages": [
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - AFI/SAFI state is not negotiated - Advertised: False Received: False Enabled: True",
"AFI: ipv4 SAFI: unicast VRF: MGMT Peer: 10.100.0.14 - AFI/SAFI state is not negotiated - Advertised: False Received: False Enabled: False",
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - AFI/SAFI state is not negotiated - Advertised: False, Received: False, Enabled: True",
"AFI: ipv4 SAFI: unicast VRF: MGMT Peer: 10.100.0.14 - AFI/SAFI state is not negotiated - Advertised: False, Received: False, Enabled: False",
],
},
},
Expand Down Expand Up @@ -978,8 +978,8 @@ def test_check_bgp_neighbor_capability(input_dict: dict[str, bool], expected: bo
"expected": {
"result": "failure",
"messages": [
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - Session has non-empty message queues - InQ: 3 OutQ: 3",
"AFI: ipv4 SAFI: unicast VRF: MGMT Peer: 10.100.0.14 - Session has non-empty message queues - InQ: 2 OutQ: 2",
"AFI: ipv4 SAFI: unicast VRF: default Peer: 10.100.0.12 - Session has non-empty message queues - InQ: 3, OutQ: 3",
"AFI: ipv4 SAFI: unicast VRF: MGMT Peer: 10.100.0.14 - Session has non-empty message queues - InQ: 2, OutQ: 2",
],
},
},
Expand Down
20 changes: 10 additions & 10 deletions tests/units/anta_tests/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,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 (src: 10.0.0.5, vrf: default, size: 100B, repeat: 2) - Unreachable"]},
},
{
"name": "failure-interface",
Expand Down Expand Up @@ -187,7 +187,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 (src: Management0, vrf: default, size: 100B, repeat: 2) - Unreachable"]},
},
{
"name": "failure-size",
Expand All @@ -209,7 +209,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 (src: Management0, vrf: default, size: 1501B, repeat: 5, df-bit: enabled) - Unreachable"]},
},
{
"name": "success",
Expand Down Expand Up @@ -330,7 +330,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 @@ -363,7 +363,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 @@ -412,7 +412,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 @@ -450,9 +450,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 @@ -498,7 +498,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"],
},
},
]
16 changes: 8 additions & 8 deletions tests/units/anta_tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@
"inputs": {"interfaces": [{"name": "Ethernet2", "status": "up"}, {"name": "Ethernet8", "status": "up"}, {"name": "Ethernet3", "status": "up"}]},
"expected": {
"result": "failure",
"messages": ["Ethernet8 - Expected: up/up Actual: down/down"],
"messages": ["Ethernet8 - Expected: up/up, Actual: down/down"],
},
},
{
Expand All @@ -1150,7 +1150,7 @@
},
"expected": {
"result": "failure",
"messages": ["Ethernet8 - Expected: up/up Actual: up/down"],
"messages": ["Ethernet8 - Expected: up/up, Actual: up/down"],
},
},
{
Expand All @@ -1166,7 +1166,7 @@
"inputs": {"interfaces": [{"name": "PortChannel100", "status": "up"}]},
"expected": {
"result": "failure",
"messages": ["Port-Channel100 - Expected: up/up Actual: down/lowerLayerDown"],
"messages": ["Port-Channel100 - Expected: up/up, Actual: down/lowerLayerDown"],
},
},
{
Expand All @@ -1191,8 +1191,8 @@
"expected": {
"result": "failure",
"messages": [
"Ethernet2 - Expected: up/down Actual: up/unknown",
"Ethernet8 - Expected: up/up Actual: up/down",
"Ethernet2 - Expected: up/down, Actual: up/unknown",
"Ethernet8 - Expected: up/up, Actual: up/down",
],
},
},
Expand All @@ -1218,9 +1218,9 @@
"expected": {
"result": "failure",
"messages": [
"Ethernet2 - Expected: down Actual: up",
"Ethernet8 - Expected: down Actual: up",
"Ethernet3 - Expected: down Actual: up",
"Ethernet2 - Expected: down, Actual: up",
"Ethernet8 - Expected: down, Actual: up",
"Ethernet3 - Expected: down, Actual: up",
],
},
},
Expand Down
8 changes: 4 additions & 4 deletions tests/units/anta_tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
},
"expected": {
"result": "failure",
"messages": ["Server 10.14.0.10 (VRF: default Priority: 0) - Not configured", "Server 10.14.0.21 (VRF: MGMT Priority: 1) - Not configured"],
"messages": ["Server 10.14.0.10 (VRF: default, Priority: 0) - Not configured", "Server 10.14.0.21 (VRF: MGMT, Priority: 1) - Not configured"],
},
},
{
Expand All @@ -109,9 +109,9 @@
"expected": {
"result": "failure",
"messages": [
"Server 10.14.0.1 (VRF: CS Priority: 0) - Incorrect priority - Priority: 1",
"Server 10.14.0.11 (VRF: default Priority: 0) - Not configured",
"Server 10.14.0.110 (VRF: MGMT Priority: 0) - Not configured",
"Server 10.14.0.1 (VRF: CS, Priority: 0) - Incorrect priority - Priority: 1",
"Server 10.14.0.11 (VRF: default, Priority: 0) - Not configured",
"Server 10.14.0.110 (VRF: MGMT, Priority: 0) - Not configured",
],
},
},
Expand Down
14 changes: 7 additions & 7 deletions tests/units/anta_tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@
"expected": {
"result": "failure",
"messages": [
"1.1.1.1 (Preferred: True Stratum: 1) - Bad association - Condition: candidate Stratum: 2",
"2.2.2.2 (Preferred: False Stratum: 2) - Bad association - Condition: sys.peer Stratum: 2",
"3.3.3.3 (Preferred: False Stratum: 2) - Bad association - Condition: sys.peer Stratum: 3",
"1.1.1.1 (Preferred: True, Stratum: 1) - Bad association - Condition: candidate, Stratum: 2",
"2.2.2.2 (Preferred: False, Stratum: 2) - Bad association - Condition: sys.peer, Stratum: 2",
"3.3.3.3 (Preferred: False, Stratum: 2) - Bad association - Condition: sys.peer, Stratum: 3",
],
},
},
Expand Down Expand Up @@ -463,7 +463,7 @@
},
"expected": {
"result": "failure",
"messages": ["3.3.3.3 (Preferred: False Stratum: 1) - Not configured"],
"messages": ["3.3.3.3 (Preferred: False, Stratum: 1) - Not configured"],
},
},
{
Expand All @@ -490,9 +490,9 @@
"expected": {
"result": "failure",
"messages": [
"1.1.1.1 (Preferred: True Stratum: 1) - Bad association - Condition: candidate Stratum: 1",
"2.2.2.2 (Preferred: False Stratum: 1) - Not configured",
"3.3.3.3 (Preferred: False Stratum: 1) - Not configured",
"1.1.1.1 (Preferred: True, Stratum: 1) - Bad association - Condition: candidate, Stratum: 1",
"2.2.2.2 (Preferred: False, Stratum: 1) - Not configured",
"3.3.3.3 (Preferred: False, Stratum: 1) - Not configured",
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions tests/units/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ def test_convert_categories(test_input: list[str], expected_raise: AbstractConte
@pytest.mark.parametrize(
("input_data", "expected_output"),
[
pytest.param({"advertised": True, "received": True, "enabled": True}, "Advertised: True Received: True Enabled: True", id="multiple entry, all True"),
pytest.param({"advertised": False, "received": False}, "Advertised: False Received: False", id="multiple entry, all False"),
pytest.param({"advertised": True, "received": True, "enabled": True}, "Advertised: True, Received: True, Enabled: True", id="multiple entry, all True"),
pytest.param({"advertised": False, "received": False}, "Advertised: False, Received: False", id="multiple entry, all False"),
pytest.param({}, "", id="empty dict"),
pytest.param({"test": True}, "Test: True", id="single entry"),
],
Expand Down

0 comments on commit ba74697

Please sign in to comment.