summaryrefslogtreecommitdiffstats
path: root/tests/units/cli/nrfu
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/cli/nrfu')
-rw-r--r--tests/units/cli/nrfu/test__init__.py17
-rw-r--r--tests/units/cli/nrfu/test_commands.py16
2 files changed, 32 insertions, 1 deletions
diff --git a/tests/units/cli/nrfu/test__init__.py b/tests/units/cli/nrfu/test__init__.py
index 052c7c3..a9dcd9c 100644
--- a/tests/units/cli/nrfu/test__init__.py
+++ b/tests/units/cli/nrfu/test__init__.py
@@ -24,6 +24,14 @@ def test_anta_nrfu_help(click_runner: CliRunner) -> None:
assert "Usage: anta nrfu" in result.output
+def test_anta_nrfu_wrong_subcommand(click_runner: CliRunner) -> None:
+ """Test anta nrfu toast."""
+ result = click_runner.invoke(anta, ["nrfu", "oook"])
+ assert result.exit_code == ExitCode.USAGE_ERROR
+ assert "Usage: anta nrfu" in result.output
+ assert "No such command 'oook'." in result.output
+
+
def test_anta_nrfu(click_runner: CliRunner) -> None:
"""Test anta nrfu, catalog is given via env."""
result = click_runner.invoke(anta, ["nrfu"])
@@ -32,6 +40,15 @@ def test_anta_nrfu(click_runner: CliRunner) -> None:
assert "Tests catalog contains 1 tests" in result.output
+def test_anta_nrfu_dry_run(click_runner: CliRunner) -> None:
+ """Test anta nrfu --dry-run, catalog is given via env."""
+ result = click_runner.invoke(anta, ["nrfu", "--dry-run"])
+ assert result.exit_code == ExitCode.OK
+ assert "ANTA Inventory contains 3 devices" in result.output
+ assert "Tests catalog contains 1 tests" in result.output
+ assert "Dry-run" in result.output
+
+
def test_anta_password_required(click_runner: CliRunner) -> None:
"""Test that password is provided."""
env = default_anta_env()
diff --git a/tests/units/cli/nrfu/test_commands.py b/tests/units/cli/nrfu/test_commands.py
index 4ea40b7..e2b5031 100644
--- a/tests/units/cli/nrfu/test_commands.py
+++ b/tests/units/cli/nrfu/test_commands.py
@@ -54,6 +54,20 @@ def test_anta_nrfu_table(click_runner: CliRunner) -> None:
assert "dummy │ VerifyEOSVersion │ success" in result.output
+def test_anta_nrfu_table_group_by_device(click_runner: CliRunner) -> None:
+ """Test anta nrfu, catalog is given via env."""
+ result = click_runner.invoke(anta, ["nrfu", "table", "--group-by", "device"])
+ assert result.exit_code == ExitCode.OK
+ assert "Summary per device" in result.output
+
+
+def test_anta_nrfu_table_group_by_test(click_runner: CliRunner) -> None:
+ """Test anta nrfu, catalog is given via env."""
+ result = click_runner.invoke(anta, ["nrfu", "table", "--group-by", "test"])
+ assert result.exit_code == ExitCode.OK
+ assert "Summary per test" in result.output
+
+
def test_anta_nrfu_text(click_runner: CliRunner) -> None:
"""Test anta nrfu, catalog is given via env."""
result = click_runner.invoke(anta, ["nrfu", "text"])
@@ -66,7 +80,7 @@ def test_anta_nrfu_json(click_runner: CliRunner) -> None:
result = click_runner.invoke(anta, ["nrfu", "json"])
assert result.exit_code == ExitCode.OK
assert "JSON results" in result.output
- match = re.search(r"\[\n {[\s\S]+ }\n\]", result.output)
+ match = re.search(r"\[\n {2}{[\s\S]+ {2}}\n\]", result.output)
assert match is not None
result_list = json.loads(match.group())
for res in result_list: