Skip to content

Commit 908dbae

Browse files
committed
Update tests for install onboarding flow
1 parent 8fc5c77 commit 908dbae

3 files changed

Lines changed: 21 additions & 16 deletions

File tree

tests/test_claude_sage_enforcement.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def test_allows_npx_sage_wrapped_shell_command():
5050
assert result.stderr == ""
5151

5252

53-
def test_blocks_direct_file_tool():
53+
def test_allows_direct_file_tool():
5454
result = run_hook({"tool_name": "Read", "tool_input": {"file_path": "README.md"}})
5555

56-
assert result.returncode == 2
57-
assert "Use SAGE MCP tools instead" in result.stderr
56+
assert result.returncode == 0
57+
assert result.stderr == ""
5858

5959

6060
def test_blocks_subagent_without_sage_instructions():

tests/test_cli_basic.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ def test_cli_first_use_auto_installs_global_agent_enforcement(self, tmp_path, mo
191191
assert "sage run -- <command>" in content
192192
assert "npx -y psycgod-sage run -- <command>" in content
193193
assert "start through SAGE automatically" in content
194-
assert "mcp__sage__sage_read_file" in content
195-
assert "mcp__sage__sage_tree" in content
194+
assert "Use native file/search/edit tools normally" in content
195+
assert "SAGE MCP tools are unavailable" in content
196196
assert "Please help me with my general book in this folder" in content
197197
assert "ð" not in content
198198
assert "â" not in content
@@ -201,8 +201,8 @@ def test_cli_first_use_auto_installs_global_agent_enforcement(self, tmp_path, mo
201201
assert "PreToolUse" in settings
202202
assert "Bash(sage run -- *)" in settings
203203
assert "Bash(npx -y psycgod-sage run -- *)" in settings
204-
assert "Read(*)" in settings
205-
assert "mcpServers" in settings
204+
assert "Read(*)" not in settings
205+
assert "mcpServers" not in settings
206206
parsed_settings = json.loads(settings)
207207
hook_config = parsed_settings["hooks"]["PreToolUse"][0]["hooks"][0]
208208
assert hook_config["type"] == "command"
@@ -229,17 +229,21 @@ def test_project_install_adds_local_claude_and_agents_files(self, tmp_path):
229229

230230
claude = (tmp_path / "CLAUDE.md").read_text(encoding="utf-8")
231231
assert "SAGE Integration - MANDATORY" in claude
232-
assert "mcp__sage__sage_edit_file" in claude
232+
assert "Use native file/search/edit tools normally" in claude
233233
assert "start through SAGE automatically" in claude
234234

235235
def test_cli_install_command_runs_system_enforcement(self, tmp_path, monkeypatch):
236-
from sage import install
237-
from sage.cli import install_command
236+
from sage import cli
238237

239-
monkeypatch.setattr(install.Path, "home", staticmethod(lambda: tmp_path))
240-
assert install_command() == 0
241-
assert (tmp_path / ".claude" / "CLAUDE.md").exists()
242-
assert (tmp_path / ".codex" / "AGENTS.md").exists()
238+
calls: list[tuple[bool, bool]] = []
239+
240+
def fake_activate_command(*, force: bool = False, project: bool = True) -> int:
241+
calls.append((force, project))
242+
return 0
243+
244+
monkeypatch.setattr(cli, "activate_command", fake_activate_command)
245+
assert cli.install_command(force=True, project=False, wait=False) == 0
246+
assert calls == [(True, False)]
243247

244248
def test_auto_enforcement_warning_does_not_block_commands(self, monkeypatch):
245249
from sage import install

tests/test_public_release_docs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ def test_readme_public_positioning():
3131

3232
assert "# SAGE" in readme
3333
assert "pip install psycgod-sage" in readme
34-
assert "## Start Here: Install, Activate, Then Use Any AI Agent" in readme
34+
assert "## Start Here: Install SAGE, Then Use Any AI Agent" in readme
35+
assert "sage install" in readme
3536
assert "sage doctor --activation" in readme
3637
assert "npx -y psycgod-sage doctor --activation" in readme
37-
assert "After activation, restart any open AI-agent sessions" in readme
38+
assert "After install, restart any open AI-agent sessions" in readme
3839
assert "Please help me with my general book in this folder" in readme
3940
assert "Raw logs" in readme or "raw logs" in readme.lower()
4041
assert "## Known Limitations" in readme

0 commit comments

Comments
 (0)