mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: new configurations for APK/Java/Python/Yum
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
+22
-11
@@ -32,20 +32,27 @@ def write_config(tmp_path, data) -> str:
|
||||
def test_validate_valid_config(tmp_path) -> None:
|
||||
config_path = write_config(tmp_path, MINIMAL_CONFIG)
|
||||
result = runner.invoke(cli.app, ["validate", "--config", config_path])
|
||||
assert result.exit_code == 0 # nosec B101
|
||||
assert "is valid" in result.stdout # nosec B101
|
||||
assert result.exit_code == 0
|
||||
assert "is valid" in result.stdout
|
||||
|
||||
|
||||
def test_validate_without_config_fails() -> None:
|
||||
result = runner.invoke(cli.app, ["validate"])
|
||||
assert result.exit_code != 0 # nosec B101
|
||||
assert "either --config or --config-env" in result.output # nosec B101
|
||||
assert result.exit_code != 0
|
||||
assert "either --config or --config-env" in result.output
|
||||
|
||||
|
||||
def test_list_modules() -> None:
|
||||
result = runner.invoke(cli.app, ["list-modules"])
|
||||
assert result.exit_code == 0 # nosec B101
|
||||
assert set(result.stdout.splitlines()) == {"apt", "certificates"} # nosec B101
|
||||
assert result.exit_code == 0
|
||||
assert set(result.stdout.splitlines()) == {
|
||||
"apk",
|
||||
"apt",
|
||||
"certificates",
|
||||
"java",
|
||||
"python",
|
||||
"yum",
|
||||
}
|
||||
|
||||
|
||||
def test_apply_skips_irrelevant_modules(tmp_path, caplog) -> None:
|
||||
@@ -55,9 +62,13 @@ def test_apply_skips_irrelevant_modules(tmp_path, caplog) -> None:
|
||||
result = runner.invoke(
|
||||
cli.app, ["apply", "--config", config_path, "--dst", str(dst), "-v"]
|
||||
)
|
||||
assert result.exit_code == 0 # nosec B101
|
||||
assert "skipping module apt" in caplog.text # nosec B101
|
||||
assert "skipping module certificates" in caplog.text # nosec B101
|
||||
assert result.exit_code == 0
|
||||
assert "skipping module apk" in caplog.text
|
||||
assert "skipping module java" in caplog.text
|
||||
assert "skipping module apt" in caplog.text
|
||||
assert "skipping module certificates" in caplog.text
|
||||
assert "skipping module yum" in caplog.text
|
||||
assert "skipping module python" in caplog.text
|
||||
|
||||
|
||||
def test_apply_runs_relevant_module(tmp_path, monkeypatch) -> None:
|
||||
@@ -74,8 +85,8 @@ def test_apply_runs_relevant_module(tmp_path, monkeypatch) -> None:
|
||||
cli.app, ["apply", "--config", config_path, "--dst", str(dst)]
|
||||
)
|
||||
|
||||
assert result.exit_code == 0 # nosec B101
|
||||
assert (dst / "usr/local/share/ca-certificates/my-ca.crt").read_bytes() == b"fake" # nosec B101
|
||||
assert result.exit_code == 0
|
||||
assert (dst / "usr/local/share/ca-certificates/my-ca.crt").read_bytes() == b"fake"
|
||||
mock_run.assert_called_once()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user