diff --git a/src/pyfaradaycup/decommutator/TODO.md b/src/pyfaradaycup/decommutator/TODO.md index 8c86f10..e9ae9d4 100644 --- a/src/pyfaradaycup/decommutator/TODO.md +++ b/src/pyfaradaycup/decommutator/TODO.md @@ -145,7 +145,7 @@ Most of these can be tested with `monkeypatch`, without new data files. ### Command line options -- [ ] **Test the usage errors from `pfc_decommutator`**: an `--apid` that is not hexadecimal and `--stcorrect`. +- [ ] **Test that `--stcorrect` raises an error**, unless it is removed first. ### Comparing CDF files diff --git a/tests/decommutator/test_decommutator.py b/tests/decommutator/test_decommutator.py index c6d3aa1..0557a50 100644 --- a/tests/decommutator/test_decommutator.py +++ b/tests/decommutator/test_decommutator.py @@ -330,6 +330,18 @@ def test_pfc_decommutator_l0file_option_removed(tmp_path: Path) -> None: assert not list(tmp_path.glob("*.log")) +@pytest.mark.parametrize("apid", ["352x", "xyz", "", "0x", "3.5"]) +def test_pfc_decommutator_apid_not_hexadecimal(tmp_path: Path, apid: str) -> None: + """Test that an --apid that is not hexadecimal is a usage error.""" + result = CliRunner().invoke( + pfc_decommutator, + [f"--l05dir={tmp_path}", f"--logdir={tmp_path}", f"--apid={apid}", str(l0file)], + ) + assert result.exit_code == click.UsageError.exit_code + assert "is not a hexadecimal integer" in result.output + assert not list(tmp_path.iterdir()) + + def test_warn_about_ineffective_options(caplog: pytest.LogCaptureFixture) -> None: """Test that options with no effect are logged as warnings.""" with caplog.at_level(logging.WARNING, logger="pyfaradaycup"):