From bdad52f4ec5e61e90e445b58251047e0d7fdfaad Mon Sep 17 00:00:00 2001 From: Container Date: Tue, 11 Aug 2026 21:16:24 +0000 Subject: [PATCH] Add test for CLI --export-associated --- tests/test_cli_export_associated.py | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/test_cli_export_associated.py diff --git a/tests/test_cli_export_associated.py b/tests/test_cli_export_associated.py new file mode 100644 index 00000000..67a8ec27 --- /dev/null +++ b/tests/test_cli_export_associated.py @@ -0,0 +1,59 @@ +from pathlib import Path + +from click.testing import CliRunner + +from imagedephi.main import imagedephi + + +def test_cli_export_associated( + cli_runner: CliRunner, + tmp_path: Path, + data_dir: Path, + test_image_svs: Path, +) -> None: + """Exercise the CLI with --export-associated and verify output directory creation.""" + input_image = test_image_svs + output_dir = tmp_path / "output" + output_dir.mkdir() + + result = cli_runner.invoke( + imagedephi, + [ + "run", + str(input_image), + "--output-dir", + str(output_dir), + "-e", + ], + ) + + assert result.exit_code == 0 + associated_dirs = [d for d in output_dir.iterdir() if "Associated" in d.name and d.is_dir()] + assert len(associated_dirs) == 1 + + +def test_cli_export_associated_long_flag( + cli_runner: CliRunner, + tmp_path: Path, + data_dir: Path, + test_image_svs: Path, +) -> None: + """Verify the long --export-associated flag creates the directory.""" + input_image = test_image_svs + output_dir = tmp_path / "output" + output_dir.mkdir() + + result = cli_runner.invoke( + imagedephi, + [ + "run", + str(input_image), + "--output-dir", + str(output_dir), + "--export-associated", + ], + ) + + assert result.exit_code == 0 + associated_dirs = [d for d in output_dir.iterdir() if "Associated" in d.name and d.is_dir()] + assert len(associated_dirs) == 1