Add test cases verifying root inspect and nested forensics inspect CLI execution paths

This commit is contained in:
venus
2026-07-18 02:44:54 -05:00
parent 05144a2dda
commit b6c73e46f2

View File

@@ -248,6 +248,37 @@ def test_forensics_inspect_cli_success():
assert "Detected Type" in result.output assert "Detected Type" in result.output
assert "PNG Image" in result.output assert "PNG Image" in result.output
def test_root_inspect_cli_success():
"""
Verifies that 'ctf inspect' successfully runs at the root level and prints
the metadata in a formatted table.
"""
from ctf.main import cli
runner = CliRunner()
test_file = TEST_ENV / "test_file_root.png"
with open(test_file, "wb") as f:
f.write(b"\x89PNG\r\n\x1a\n")
result = runner.invoke(cli, ["inspect", str(test_file)])
assert result.exit_code == 0
assert "Metadata: test_file_root.png" in result.output
assert "PNG Image" in result.output
def test_nested_inspect_cli_success():
"""
Verifies that 'ctf forensics inspect' successfully runs via the root CLI.
"""
from ctf.main import cli
runner = CliRunner()
test_file = TEST_ENV / "test_file_nested.png"
with open(test_file, "wb") as f:
f.write(b"\x89PNG\r\n\x1a\n")
result = runner.invoke(cli, ["forensics", "inspect", str(test_file)])
assert result.exit_code == 0
assert "Metadata: test_file_nested.png" in result.output
assert "PNG Image" in result.output
def test_forensics_inspect_cli_missing_file(): def test_forensics_inspect_cli_missing_file():
""" """
Verifies that the CLI fails gracefully when a non-existent file path is specified. Verifies that the CLI fails gracefully when a non-existent file path is specified.