Skip to content

Commit

Permalink
fix(anta.tests): Update Interface custom type (#409)
Browse files Browse the repository at this point in the history
* fix: Update Interface model

* fix: Added pytest + separator
  • Loading branch information
carl-baillargeon committed Sep 22, 2023
1 parent 9c74238 commit 8c31823
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion anta/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def aaa_group_prefix(v: str) -> str:
AAAAuthMethod = Annotated[str, AfterValidator(aaa_group_prefix)]
Vlan = Annotated[int, Field(ge=0, le=4094)]
TestStatus = Literal["unset", "success", "failure", "error", "skipped"]
Interface = Annotated[str, Field(pattern=r"^(Ethernet|Fabric|Loopback|Management|Port-Channel|Tunnel|Vlan|Vxlan)[0-9]+(\/[0-9]+)*$")]
Interface = Annotated[str, Field(pattern=r"^(Ethernet|Fabric|Loopback|Management|Port-Channel|Tunnel|Vlan|Vxlan)[0-9]+(\/[0-9]+)*(\.[0-9]+)?$")]
Afi = Literal["ipv4", "ipv6", "vpn-ipv4", "vpn-ipv6", "evpn", "rt-membership"]
Safi = Literal["unicast", "multicast", "labeled-unicast"]
2 changes: 1 addition & 1 deletion anta/tests/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test(self) -> None:
intf_wrong_state = []

for interface_status in self.inputs.interfaces:
intf_status = get_value(command_output["interfaceDescriptions"], interface_status.interface)
intf_status = get_value(command_output["interfaceDescriptions"], interface_status.interface, separator=";")
if intf_status is None:
intf_not_configured.append(interface_status.interface)
continue
Expand Down
13 changes: 13 additions & 0 deletions tests/units/anta_tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@
},
"expected": {"result": "success"},
},
{
"name": "success-sub-interfaces",
"test": VerifyInterfacesStatus,
"eos_data": [
{
"interfaceDescriptions": {
"Ethernet52/1.1963": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"},
}
}
],
"inputs": {"interfaces": [{"interface": "Ethernet52/1.1963", "state": "up"}]},
"expected": {"result": "success"},
},
{
"name": "failure-not-configured",
"test": VerifyInterfacesStatus,
Expand Down

0 comments on commit 8c31823

Please sign in to comment.