diff --git a/tests/test_cli.py b/tests/test_cli.py index 447244b..9bef725 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,6 +3,7 @@ from unittest.mock import patch import numpy as np +import pytest from typer.testing import CliRunner from bimorph_mirror_analysis import __version__ @@ -11,7 +12,14 @@ runner = CliRunner() -def test_app(): +@pytest.mark.parametrize( + ["outpath"], + [ + ["tests/data/out.csv"], + [False], + ], +) +def test_app(outpath: str | bool): with ( patch("bimorph_mirror_analysis.__main__.np.savetxt") as mock_np_save, patch( @@ -19,7 +27,22 @@ def test_app(): ) as mock_calculate_optimal_voltages, ): mock_calculate_optimal_voltages.return_value = np.array([72.14, 50.98, 18.59]) - result = runner.invoke(app, ["calculate-voltages", "tests/data/raw_data.csv"]) + if outpath is not False: + print("\n\n\n\n\n\n") + result = runner.invoke( + app, + [ + "calculate-voltages", + "tests/data/raw_data.csv", + "--output_path", + f"{outpath}", + ], + ) + print("aaa") + elif not outpath: + result = runner.invoke( + app, ["calculate-voltages", "tests/data/raw_data.csv"] + ) mock_np_save.assert_called_once() mock_calculate_optimal_voltages.assert_called_with("tests/data/raw_data.csv") assert "The optimal voltages are: [72.14, 50.98, 18.59]" in result.stdout