Skip to content

Commit a8158fd

Browse files
Updated unit tests
1 parent 4a82676 commit a8158fd

File tree

2 files changed

+96
-23
lines changed

2 files changed

+96
-23
lines changed

anta/tests/routing/isis.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
def _get_adjacency_segment_data_by_neighbor(neighbor: str, instance: str, vrf: str, command_output: dict[str, Any]) -> dict[str, Any] | None:
1818
"""Extract data related to an IS-IS interface for testing."""
1919
search_path = f"vrfs.{vrf}.isisInstances.{instance}.adjacencySegments"
20-
if get_value(dictionary=command_output, key=search_path, default=None) is None:
20+
if (isis_instance := get_value(dictionary=command_output, key=search_path, default=None)) is None:
2121
return None
2222

23-
isis_instance = get_value(dictionary=command_output, key=search_path, default=None)
24-
2523
return next(
2624
(segment_data for segment_data in isis_instance if neighbor == segment_data["ipAddress"]),
2725
None,

tests/units/anta_tests/routing/test_isis.py

+95-20
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,27 @@
5959
}
6060
}
6161
}
62-
}
62+
},
63+
"customer": {
64+
"isisInstances": {
65+
"CORE-ISIS": {
66+
"neighbors": {
67+
"0168.0000.0112": {
68+
"adjacencies": [
69+
{
70+
"hostname": "s1-p02",
71+
"circuitId": "87",
72+
"interfaceName": "Ethernet2",
73+
"state": "down",
74+
"lastHelloTime": 1713688405,
75+
"routerIdV4": "1.0.0.112",
76+
}
77+
]
78+
}
79+
}
80+
}
81+
}
82+
},
6383
}
6484
},
6585
],
@@ -91,31 +111,31 @@
91111
},
92112
},
93113
},
94-
"customer": {
95-
"isisInstances": {
96-
"CORE-ISIS": {
97-
"neighbors": {
98-
"0168.0000.0112": {
99-
"adjacencies": [
100-
{
101-
"hostname": "s1-p02",
102-
"circuitId": "87",
103-
"interfaceName": "Ethernet2",
104-
"state": "up",
105-
"lastHelloTime": 1713688405,
106-
"routerIdV4": "1.0.0.112",
107-
}
108-
]
109-
}
114+
},
115+
"customer": {
116+
"isisInstances": {
117+
"CORE-ISIS": {
118+
"neighbors": {
119+
"0168.0000.0112": {
120+
"adjacencies": [
121+
{
122+
"hostname": "s1-p02",
123+
"circuitId": "87",
124+
"interfaceName": "Ethernet2",
125+
"state": "up",
126+
"lastHelloTime": 1713688405,
127+
"routerIdV4": "1.0.0.112",
128+
}
129+
]
110130
}
111131
}
112132
}
113-
},
114-
}
133+
}
134+
},
115135
}
116136
},
117137
],
118-
"inputs": None,
138+
"inputs": {"check_all_vrfs": True},
119139
"expected": {"result": "success"},
120140
},
121141
{
@@ -177,6 +197,61 @@
177197
"messages": ["IS-IS is not configured on device"],
178198
},
179199
},
200+
{
201+
"name": "failure different vrfs",
202+
"test": VerifyISISNeighborState,
203+
"eos_data": [
204+
{
205+
"vrfs": {
206+
"default": {
207+
"isisInstances": {
208+
"CORE-ISIS": {
209+
"neighbors": {
210+
"0168.0000.0111": {
211+
"adjacencies": [
212+
{
213+
"hostname": "s1-p01",
214+
"circuitId": "83",
215+
"interfaceName": "Ethernet1",
216+
"state": "up",
217+
"lastHelloTime": 1713688408,
218+
"routerIdV4": "1.0.0.111",
219+
}
220+
]
221+
},
222+
},
223+
},
224+
},
225+
},
226+
"customer": {
227+
"isisInstances": {
228+
"CORE-ISIS": {
229+
"neighbors": {
230+
"0168.0000.0112": {
231+
"adjacencies": [
232+
{
233+
"hostname": "s1-p02",
234+
"circuitId": "87",
235+
"interfaceName": "Ethernet2",
236+
"state": "down",
237+
"lastHelloTime": 1713688405,
238+
"routerIdV4": "1.0.0.112",
239+
}
240+
]
241+
}
242+
}
243+
}
244+
}
245+
},
246+
}
247+
},
248+
],
249+
"inputs": {"check_all_vrfs": True},
250+
"expected": {
251+
"result": "failure",
252+
"messages": ["Instance: CORE-ISIS VRF: customer Interface: Ethernet2 - Session (adjacency) down"],
253+
},
254+
},
180255
{
181256
"name": "success only default vrf",
182257
"test": VerifyISISNeighborCount,

0 commit comments

Comments
 (0)