Skip to content

Commit

Permalink
fix pytest test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
emilarista committed Mar 6, 2025
1 parent 5b5b51c commit c3aee91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions anta/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def test(self) -> None:
unitsenteringmaintenance.append(unit)
entering = True
if info["adminState"] == "underMaintenance":
causes.append("quiesce is configured")
causes.append("Quiesce is configured")
if info["onBootMaintenance"]:
causes.append("On-boot maintenance is configured")
if info["intfsViolatingTrafficThreshold"]:
Expand All @@ -400,10 +400,13 @@ def test(self) -> None:
# Building the error message.
else:
message = ""
unitsundermaintenance = ", ".join(unitsundermaintenance)
unitsenteringmaintenance = " ".join(unitsenteringmaintenance)
causes = ", ".join(causes)
if under:
message += f"Units under maintenance: '{unitsundermaintenance}'. "
if entering:
message += f"Units entering maintenance: '{unitsenteringmaintenance}'. "
if len(causes) > 0:
message += f"Possible causes: '{causes}'"
message += f"Possible causes: {causes}"
self.result.is_failure(message)
15 changes: 11 additions & 4 deletions tests/units/anta_tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@
"warnings": ["Maintenance Mode is disabled."],
},
],
"inputs": None,
"expected": {"result": "success"},
},
{
Expand All @@ -530,6 +531,7 @@
"vrfs": {},
},
],
"inputs": None,
"expected": {"result": "success"},
},
{
Expand Down Expand Up @@ -561,6 +563,7 @@
"vrfs": {},
},
],
"inputs": None,
"expected": {"result": "success"},
},
{
Expand Down Expand Up @@ -592,10 +595,11 @@
"vrfs": {},
},
],
"inputs": None,
"expected": {
"result": "failure",
"messages": [
"The following units are currently under maintenance: '['mlag']'. Possible causes: ['quiesce is configured']",
"Units under maintenance: 'mlag'. Possible causes: Quiesce is configured",
],
},
},
Expand Down Expand Up @@ -628,10 +632,11 @@
"vrfs": {},
},
],
"inputs": None,
"expected": {
"result": "failure",
"messages": [
"Units under maintenance: '['mlag']'. Units entering maintenance: '['System']' Possible causes: ['quiesce is configured','quiesce is configured']",
"Units under maintenance: 'mlag'. Units entering maintenance: 'System'. Possible causes: Quiesce is configured, Quiesce is configured",
],
},
},
Expand All @@ -655,10 +660,11 @@
"vrfs": {},
},
],
"inputs": None,
"expected": {
"result": "failure",
"messages": [
"Units under maintenance: '['System']'. Possible causes: ['On-boot maintenance is configured']",
"Units under maintenance: 'System'. Possible causes: Quiesce is configured, On-boot maintenance is configured",
],
},
},
Expand All @@ -682,10 +688,11 @@
"vrfs": {},
},
],
"inputs": None,
"expected": {
"result": "failure",
"messages": [
"Units entering maintenance: '['System']'. Possible causes: ['Interface traffic threshold violation']",
"Units entering maintenance: 'System'. Possible causes: Quiesce is configured, Interface traffic threshold violation",
],
},
},
Expand Down

0 comments on commit c3aee91

Please sign in to comment.