From 3033f0a45c2222829516f0839c28569f4e27e50f Mon Sep 17 00:00:00 2001 From: robcohen Date: Mon, 27 Apr 2026 11:47:39 -0500 Subject: [PATCH] test: accept rustledger v0.14 query error categorization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prepares the test suite for rustledger v0.14, where bare-word/empty queries are routed through the compilation path instead of the parse path. Assertions are broadened to accept either categorization so they pass on both v0.13.x and v0.14.x. The interpolation snapshot mismatch in `test_api_errors` is not addressed here — the v0.14 wording change (`cannot infer currency` → `multiple postings missing amounts`) needs `pytest --snapshot-update` run against the v0.14.x WASM artifact. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/test_core_query_shell.py | 6 ++++-- tests/test_json_api.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_core_query_shell.py b/tests/test_core_query_shell.py index 1317d7aa0..58b9e4809 100644 --- a/tests/test_core_query_shell.py +++ b/tests/test_core_query_shell.py @@ -89,7 +89,9 @@ def test_query_errors(run_query: Callable[[str], QueryResult]) -> None: run_query(".run custom_query other") with pytest.raises(QueryNotFoundError): run_query(".run unknown") - with pytest.raises(QueryParseError): + # Bare-word "asdf" was a parse error in rustledger ≤0.13; v0.14 routes + # the same input through the compilation path. Accept either. + with pytest.raises((QueryParseError, QueryCompilationError)): run_query("asdf") with pytest.raises(QueryCompilationError): run_query("select asdf") @@ -115,7 +117,7 @@ def test_query_to_file( query_shell.query_to_file(entries, "run custom_query other", "csv") with pytest.raises(QueryNotFoundError): query_shell.query_to_file(entries, "run testsetest", "csv") - with pytest.raises(QueryParseError): + with pytest.raises((QueryParseError, QueryCompilationError)): query_shell.query_to_file(entries, "asdf", "csv") with pytest.raises(QueryCompilationError): query_shell.query_to_file(entries, "select asdf", "csv") diff --git a/tests/test_json_api.py b/tests/test_json_api.py index ec9e88c42..34c2f3f19 100644 --- a/tests/test_json_api.py +++ b/tests/test_json_api.py @@ -808,7 +808,8 @@ def test_api_query_result_error(test_client: FlaskClient) -> None: query_string={"query_string": "nononono"}, ) msg = assert_api_error(response) - assert "Query parse error" in msg + # rustledger ≤0.13 → "Query parse error"; v0.14 → "Query compilation error". + assert "Query parse error" in msg or "Query compilation error" in msg def test_api_commodities_empty(