summaryrefslogtreecommitdiffstats
path: root/test/test_cli.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:58 +0000
commitba233a0cbad76b4783a03893e7bf4716fbc0f0ec (patch)
treead369728c1edbe3631c8150585659078ae5d7d0b /test/test_cli.py
parentReleasing progress-linux version 6.17.2-3~progress7.99u1. (diff)
downloadansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.tar.xz
ansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.zip
Merging upstream version 24.6.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test_cli.py')
-rw-r--r--test/test_cli.py82
1 files changed, 62 insertions, 20 deletions
diff --git a/test/test_cli.py b/test/test_cli.py
index a37a43d..b2c3320 100644
--- a/test/test_cli.py
+++ b/test/test_cli.py
@@ -1,4 +1,5 @@
"""Test cli arguments and config."""
+
from __future__ import annotations
import os
@@ -66,37 +67,77 @@ def test_ensure_config_are_equal(
@pytest.mark.parametrize(
- ("with_base", "args", "config"),
+ ("with_base", "args", "config", "expected"),
(
- (True, ["--write"], "test/fixtures/config-with-write-all.yml"),
- (True, ["--write=all"], "test/fixtures/config-with-write-all.yml"),
- (True, ["--write", "all"], "test/fixtures/config-with-write-all.yml"),
- (True, ["--write=none"], "test/fixtures/config-with-write-none.yml"),
- (True, ["--write", "none"], "test/fixtures/config-with-write-none.yml"),
- (
+ pytest.param(
+ True,
+ ["--fix"],
+ "test/fixtures/config-with-write-all.yml",
+ ["all"],
+ id="1",
+ ),
+ pytest.param(
+ True,
+ ["--fix=all"],
+ "test/fixtures/config-with-write-all.yml",
+ ["all"],
+ id="2",
+ ),
+ pytest.param(
+ True,
+ ["--fix", "all"],
+ "test/fixtures/config-with-write-all.yml",
+ ["all"],
+ id="3",
+ ),
+ pytest.param(
True,
- ["--write=rule-tag,rule-id"],
+ ["--fix=none"],
+ "test/fixtures/config-with-write-none.yml",
+ [],
+ id="4",
+ ),
+ pytest.param(
+ True,
+ ["--fix", "none"],
+ "test/fixtures/config-with-write-none.yml",
+ [],
+ id="5",
+ ),
+ pytest.param(
+ True,
+ ["--fix=rule-tag,rule-id"],
"test/fixtures/config-with-write-subset.yml",
+ ["rule-tag", "rule-id"],
+ id="6",
),
- (
+ pytest.param(
True,
- ["--write", "rule-tag,rule-id"],
+ ["--fix", "rule-tag,rule-id"],
"test/fixtures/config-with-write-subset.yml",
+ ["rule-tag", "rule-id"],
+ id="7",
),
- (
+ pytest.param(
True,
- ["--write", "rule-tag", "--write", "rule-id"],
+ ["--fix", "rule-tag", "--fix", "rule-id"],
"test/fixtures/config-with-write-subset.yml",
+ ["rule-tag", "rule-id"],
+ id="8",
),
- (
+ pytest.param(
False,
- ["--write", "examples/playbooks/example.yml"],
+ ["--fix", "examples/playbooks/example.yml"],
"test/fixtures/config-with-write-all.yml",
+ ["all"],
+ id="9",
),
- (
+ pytest.param(
False,
- ["--write", "examples/playbooks/example.yml", "non-existent.yml"],
+ ["--fix", "examples/playbooks/example.yml", "non-existent.yml"],
"test/fixtures/config-with-write-all.yml",
+ ["all"],
+ id="10",
),
),
)
@@ -105,21 +146,22 @@ def test_ensure_write_cli_does_not_consume_lintables(
with_base: bool,
args: list[str],
config: str,
+ expected: list[str],
) -> None:
- """Check equality of the CLI --write options to config files."""
+ """Check equality of the CLI --fix options to config files."""
cli_parser = cli.get_cli_parser()
command = base_arguments + args if with_base else args
options = cli_parser.parse_args(command)
file_config = cli.load_config(config)[0]
- file_value = file_config.get("write_list")
+ file_config.get("write_list")
orig_cli_value = options.write_list
- cli_value = cli.WriteArgAction.merge_write_list_config(
+ cli_value = cli.WriteArgAction.merge_fix_list_config(
from_file=[],
from_cli=orig_cli_value,
)
- assert file_value == cli_value
+ assert cli_value == expected
def test_config_can_be_overridden(base_arguments: list[str]) -> None: