diff --git a/tests/segmentation/test_cli.py b/tests/segmentation/test_cli.py index a2e35d2e06f7f30f33da2aef1e22793d65bf8194..75838d12daf159341326cf0aa5abd0eab399ef6b 100644 --- a/tests/segmentation/test_cli.py +++ b/tests/segmentation/test_cli.py @@ -345,6 +345,43 @@ def test_evaluate_lwnet_drive(session_tmp_path): ) +@pytest.mark.slow +@pytest.mark.skip_if_rc_var_not_set("datadir.drive") +def test_view_lwnet_drive(session_tmp_path): + from mednet.libs.segmentation.scripts.view import view + + runner = CliRunner() + + with stdout_logging() as buf: + output_folder = session_tmp_path / "segmentation-standalone" + result = runner.invoke( + view, + [ + "-vv", + f"--predictions={str(output_folder / 'predictions.json')}", + f"--output-folder={str(output_folder)}", + ], + ) + _assert_exit_0(result) + + assert len(list((output_folder / "training" / "images").glob("*.png"))) == 20 + assert len(list((output_folder / "test" / "images").glob("*.png"))) == 20 + + keywords = { + r"^Creating 20 visualisations for split.*$": 2, + r"^Set --threshold.*$": 1, + } + buf.seek(0) + logging_output = buf.read() + + for k, v in keywords.items(): + assert _str_counter(k, logging_output) == v, ( + f"Count for string '{k}' appeared " + f"({_str_counter(k, logging_output)}) " + f"instead of the expected {v}:\nOutput:\n{logging_output}" + ) + + @pytest.mark.slow @pytest.mark.skip_if_rc_var_not_set("datadir.drive") def test_train_lwnet_drive_from_checkpoint(tmp_path):