Skip to content

Commit

Permalink
Merge branch 'main' into anta-classvar
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored Oct 28, 2024
2 parents a564778 + a76ae07 commit 779a76a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
8 changes: 6 additions & 2 deletions anta/cli/nrfu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ def print_text(ctx: click.Context) -> None:
"""Print results as simple text."""
console.print()
for test in _get_result_manager(ctx).results:
message = f" ({test.messages[0]!s})" if len(test.messages) > 0 else ""
console.print(f"{test.name} :: {test.test} :: [{test.result}]{test.result.upper()}[/{test.result}]{message}", highlight=False)
if len(test.messages) <= 1:
message = test.messages[0] if len(test.messages) == 1 else ""
console.print(f"{test.name} :: {test.test} :: [{test.result}]{test.result.upper()}[/{test.result}]({message})", highlight=False)
else: # len(test.messages) > 1
console.print(f"{test.name} :: {test.test} :: [{test.result}]{test.result.upper()}[/{test.result}]", highlight=False)
console.print("\n".join(f" {message}" for message in test.messages), highlight=False)


def print_jinja(results: ResultManager, template: pathlib.Path, output: pathlib.Path | None = None) -> None:
Expand Down
13 changes: 13 additions & 0 deletions tests/data/test_catalog_double_failure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
anta.tests.interfaces:
- VerifyInterfacesSpeed:
interfaces:
- name: Ethernet2
auto: False
speed: 10
- name: Ethernet3
auto: True
speed: 100
- name: Ethernet4
auto: False
speed: 2.5
1 change: 1 addition & 0 deletions tests/units/cli/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
errmsg="Invalid command",
not_exec=[],
),
"show interfaces": {},
}

MOCK_CLI_TEXT: dict[str, asynceapi.EapiCommandError | str] = {
Expand Down
13 changes: 13 additions & 0 deletions tests/units/cli/nrfu/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ def test_anta_nrfu_text(click_runner: CliRunner) -> None:
assert "leaf1 :: VerifyEOSVersion :: SUCCESS" in result.output


def test_anta_nrfu_text_multiple_failures(click_runner: CliRunner) -> None:
"""Test anta nrfu text with multiple failures, catalog is given via env."""
result = click_runner.invoke(anta, ["nrfu", "text"], env={"ANTA_CATALOG": str(DATA_DIR / "test_catalog_double_failure.yml")})
assert result.exit_code == ExitCode.OK
assert (
"""spine1 :: VerifyInterfacesSpeed :: FAILURE
Interface `Ethernet2` is not found.
Interface `Ethernet3` is not found.
Interface `Ethernet4` is not found."""
in result.output
)


def test_anta_nrfu_json(click_runner: CliRunner) -> None:
"""Test anta nrfu, catalog is given via env."""
result = click_runner.invoke(anta, ["nrfu", "json"])
Expand Down

0 comments on commit 779a76a

Please sign in to comment.