Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Gradata/tests/test_cli_install_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
import sys
from pathlib import Path

import pytest


AGENT_INSTALL_SMOKE_MATRIX = [
pytest.param(
"claude-code", ".claude/settings.json", "gradata:claude-code", id="claude-code-hook"
),
pytest.param("codex", ".codex/config.toml", "gradata:codex", id="codex-hook"),
pytest.param("hermes", ".hermes/config.yaml", "gradata:hermes", id="hermes-hook"),
pytest.param(
"opencode", ".config/opencode/config.json", "gradata:opencode", id="opencode-hook"
),
pytest.param("gemini", ".gemini/settings.json", "gradata:gemini", id="gemini-hook"),
pytest.param("cursor", ".cursor/mcp.json", "gradata.mcp_server", id="cursor-mcp"),
]


def _run_cli(tmp_path: Path, *args: str, env: dict[str, str] | None = None) -> subprocess.CompletedProcess[str]:
base_env = os.environ.copy()
Expand Down Expand Up @@ -40,6 +56,34 @@ def test_cli_install_agent_writes_config_under_fake_home(tmp_path: Path) -> None
assert "codex" in result.stdout


@pytest.mark.parametrize(("agent", "config_relpath", "expected_marker"), AGENT_INSTALL_SMOKE_MATRIX)
def test_cli_install_agent_smoke_matrix_with_mocked_home(
tmp_path: Path,
agent: str,
config_relpath: str,
expected_marker: str,
) -> None:
"""SDK-native one-command install writes each supported host config under fake HOME.

This is the pre-Show-HN smoke matrix replacing gradata-plugin install checks.
Hosts that are unsupported should be represented here as explicit pytest.skip(...)
entries with the tracked reason; the current SDK matrix has no silent skips.
"""
brain = tmp_path / "brain"
brain.mkdir()

result = _run_cli(tmp_path, "install", "--agent", agent, "--brain", str(brain))

assert result.returncode == 0, result.stderr
config = tmp_path / config_relpath
assert config.exists(), result.stdout
config_text = config.read_text(encoding="utf-8")
assert expected_marker in config_text
assert str(brain) in config_text
assert agent in result.stdout
assert "added" in result.stdout or "already_present" in result.stdout


def test_cli_install_agent_all_detects_existing_configs(tmp_path: Path) -> None:
brain = tmp_path / "brain"
brain.mkdir()
Expand Down
Loading