Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored Dec 18, 2024
1 parent 3c434d7 commit 58bcf8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
18 changes: 9 additions & 9 deletions anta/tests/routing/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,19 @@ class VerifyIPv4RouteType(AntaTest):
This test performs the following checks for each IPv4 route:
1. Verifies that the specified VRF is configured.
2. Verifies that the specified ipv4 route is exists in the configuration.
3. Verifies that the the specified ipv4 route is of the expected type.
2. Verifies that the specified IPv4 route is exists in the configuration.
3. Verifies that the the specified IPv4 route is of the expected type.
Expected Results
----------------
* Success: If all of the following conditions are met:
- All the specified VRFs are configured.
- All the specified ipv4 routes are found.
- All the specified ipv4 routes are of the expected type.
- All the specified IPv4 routes are found.
- All the specified IPv4 routes are of the expected type.
* Failure: If any of the following occur:
- A specified VRF is not configured.
- A specified ipv4 route is not found.
- Any specified ipv4 route is not of the expected type.
- A specified IPv4 route is not found.
- Any specified IPv4 route is not of the expected type.
Examples
--------
Expand Down Expand Up @@ -248,11 +248,11 @@ def test(self) -> None:
self.result.is_failure(f"{entry} - VRF not configured")
continue

# Verifying that the expected ipv4 route is present or not on the device
# Verifying that the expected IPv4 route is present or not on the device
if (route_data := routes_details.get(prefix)) is None:
self.result.is_failure(f"{entry} - Routes not found")
self.result.is_failure(f"{entry} - Route not found")
continue

# Verifying that the specified ipv4 routes are of the expected type.
# Verifying that the specified IPv4 routes are of the expected type.
if expected_route_type != (actual_route_type := route_data.get("routeType")):
self.result.is_failure(f"{entry} - Incorrect route type - Expected: {expected_route_type} Actual: {actual_route_type}")
1 change: 1 addition & 0 deletions docs/api/tests.routing.generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ anta_title: ANTA catalog for generic routing tests
# Tests

::: anta.tests.routing.generic

options:
show_root_heading: false
show_root_toc_entry: false
Expand Down
10 changes: 5 additions & 5 deletions tests/units/anta_tests/routing/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
"expected": {"result": "failure", "messages": ["The following route(s) are missing from the routing table of VRF default: ['10.1.0.2']"]},
},
{
"name": "Success-valid-route-type",
"name": "success-valid-route-type",
"test": VerifyIPv4RouteType,
"eos_data": [
{
Expand All @@ -325,14 +325,14 @@
"expected": {"result": "success"},
},
{
"name": "Failure-route-not-found",
"name": "failure-route-not-found",
"test": VerifyIPv4RouteType,
"eos_data": [{"vrfs": {"default": {"routes": {}}}}],
"inputs": {"routes_entries": [{"vrf": "default", "prefix": "10.10.0.1/32", "route_type": "eBGP"}]},
"expected": {"result": "failure", "messages": ["Prefix: 10.10.0.1/32 VRF: default - Routes not found"]},
"expected": {"result": "failure", "messages": ["Prefix: 10.10.0.1/32 VRF: default - Route not found"]},
},
{
"name": "Failure-invalid-route-type",
"name": "failure-invalid-route-type",
"test": VerifyIPv4RouteType,
"eos_data": [{"vrfs": {"default": {"routes": {"10.10.0.1/32": {"routeType": "eBGP"}}}}}],
"inputs": {"routes_entries": [{"vrf": "default", "prefix": "10.10.0.1/32", "route_type": "iBGP"}]},
Expand All @@ -342,7 +342,7 @@
},
},
{
"name": "Failure-vrf-not-configured",
"name": "failure-vrf-not-configured",
"test": VerifyIPv4RouteType,
"eos_data": [{"vrfs": {}}],
"inputs": {"routes_entries": [{"vrf": "default", "prefix": "10.10.0.1/32", "route_type": "eBGP"}]},
Expand Down

0 comments on commit 58bcf8a

Please sign in to comment.