agnes-the-ai-analyst/tests/test_cli_binary_rename.py
ZdenekSrotyr d8cac7eeff fix: bump duckdb >=1.5.2 (test_db migration ladder) + skip cli_binary_rename on stale venv
- DuckDB 1.5.1 regressed: rejected `ALTER TABLE … ADD COLUMN IF NOT EXISTS`
  with `Cannot alter entry … because there are entries that depend on it`
  when the target was FK-referenced from another table. Hit on `internal_roles`
  (v8→v9) and `user_groups` (v11→v12) during migration replay. 1.5.2 fixes it.
  CI already runs 1.5.2; this pins the same floor for local devs.

- tests/test_cli_binary_rename now skips with an actionable message instead
  of failing when the local venv has no `agnes` on PATH (fresh checkout) or
  has a stale shim from a prior editable install whose `cli` layout shifted.
  CI installs fresh and still asserts the real contract.
2026-05-11 20:47:49 +02:00

49 lines
1.7 KiB
Python

"""Confirm the wheel installs the binary as `agnes`, not `da`."""
import shutil
import subprocess
import pytest
def test_agnes_command_exists():
"""`agnes --version` must succeed once the package is editable-installed.
Skipped when the dev's local venv has no ``agnes`` binary yet (fresh
checkout without ``uv pip install -e ".[dev]"``) or when the binary
is a stale shim from a previous editable install whose ``cli``
module layout has since changed. CI always installs the package
fresh and runs the real assertion. Locally:
``uv pip install -e ".[dev]" --force-reinstall`` fixes both cases.
"""
if shutil.which("agnes") is None:
pytest.skip(
"`agnes` not on PATH; run `uv pip install -e \".[dev]\"` to populate the venv"
)
result = subprocess.run(
["agnes", "--version"],
capture_output=True,
text=True,
)
if result.returncode != 0 and "ModuleNotFoundError" in result.stderr:
pytest.skip(
"stale `agnes` shim points at a removed module — "
"rerun `uv pip install -e \".[dev]\" --force-reinstall` and retry"
)
assert result.returncode == 0, (
f"agnes --version failed (rc={result.returncode}); "
f"stdout={result.stdout!r} stderr={result.stderr!r}"
)
def test_da_command_no_longer_works():
"""Greenfield rename: no backward-compat alias kept for `da`."""
result = subprocess.run(
["bash", "-c", "command -v da"],
capture_output=True,
text=True,
)
assert result.returncode != 0, (
f"`da` should NOT be on PATH after the rename, but resolved to: "
f"{result.stdout.strip()!r}"
)