From 42e108ae5effd28b18cec2234f72172f8e122208 Mon Sep 17 00:00:00 2001 From: ZdenekSrotyr Date: Mon, 4 May 2026 19:15:39 +0200 Subject: [PATCH] test: reader smoke matrix on zero-grants workspace --- tests/test_reader_smoke_matrix.py | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_reader_smoke_matrix.py diff --git a/tests/test_reader_smoke_matrix.py b/tests/test_reader_smoke_matrix.py new file mode 100644 index 0000000..e33732f --- /dev/null +++ b/tests/test_reader_smoke_matrix.py @@ -0,0 +1,50 @@ +"""Reader smoke matrix — every reader CLI command on a freshly-bootstrapped +zero-grants workspace, asserts no traceback. The load-bearing test for +'nothing crashes on missing dirs'.""" + +import os +import subprocess +import sys + +import pytest + +from tests.fixtures.analyst_bootstrap import NONEXISTENT_TABLE + + +# Use `python -m cli.main` (not the `.venv/bin/agnes` shim) for the same +# iCloud-shim-race reason Task 20's fixtures use it. +AGNES = [sys.executable, "-m", "cli.main"] + + +READER_COMMANDS = [ + AGNES + ["catalog"], + AGNES + ["catalog", "--metrics"], + AGNES + ["schema", NONEXISTENT_TABLE], + AGNES + ["describe", NONEXISTENT_TABLE], + AGNES + ["query", "SELECT 1"], + AGNES + ["explore", NONEXISTENT_TABLE], + AGNES + ["disk-info"], + AGNES + ["snapshot", "list"], + AGNES + ["snapshot", "create", NONEXISTENT_TABLE, "--as", "x", "--estimate"], + AGNES + ["status"], + AGNES + ["diagnose"], + AGNES + ["auth", "whoami"], + AGNES + ["skills", "list"], + AGNES + ["skills", "show", "agnes-data-querying"], +] + + +@pytest.mark.parametrize("cmd", READER_COMMANDS, ids=lambda c: " ".join(c[3:]) if len(c) > 3 else "agnes") +def test_reader_does_not_crash_on_zero_grants(zero_grants_workspace, fastapi_test_server, cmd): + """Exit 0 (success) or exit 1 (friendly hint) is OK; tracebacks are forbidden.""" + env = os.environ.copy() + env["AGNES_LOCAL_DIR"] = str(zero_grants_workspace) + env["AGNES_SERVER"] = fastapi_test_server.url + # Token already saved by `agnes init` during fixture setup; AGNES_TOKEN + # env override would defeat that. Leave it unset and let cli.config read + # the saved token.json. + result = subprocess.run(cmd, cwd=zero_grants_workspace, env=env, + capture_output=True, text=True, timeout=30) + assert result.returncode in (0, 1), \ + f"{cmd} crashed: rc={result.returncode}\nstdout={result.stdout}\nstderr={result.stderr}" + assert "Traceback" not in result.stderr, f"{cmd} threw: {result.stderr}"