|
| 1 | +"""Tests for agent CLI commands.""" |
| 2 | + |
| 3 | +from unittest.mock import patch |
| 4 | + |
| 5 | +import pytest |
| 6 | +from click.testing import CliRunner |
| 7 | + |
| 8 | +from notebooklm.notebooklm_cli import cli |
| 9 | + |
| 10 | +from .conftest import get_cli_module |
| 11 | + |
| 12 | +agent_module = get_cli_module("agent") |
| 13 | +agent_templates_module = get_cli_module("agent_templates") |
| 14 | + |
| 15 | + |
| 16 | +@pytest.fixture |
| 17 | +def runner(): |
| 18 | + return CliRunner() |
| 19 | + |
| 20 | + |
| 21 | +class TestAgentShow: |
| 22 | + """Tests for agent show command.""" |
| 23 | + |
| 24 | + def test_agent_show_codex_displays_content(self, runner): |
| 25 | + """Test that agent show codex displays the bundled instructions.""" |
| 26 | + with patch.object( |
| 27 | + agent_module, "get_agent_source_content", return_value="# Repository Guidelines" |
| 28 | + ): |
| 29 | + result = runner.invoke(cli, ["agent", "show", "codex"]) |
| 30 | + |
| 31 | + assert result.exit_code == 0 |
| 32 | + assert "Repository Guidelines" in result.output |
| 33 | + |
| 34 | + def test_agent_show_claude_displays_content(self, runner): |
| 35 | + """Test that agent show claude displays the bundled instructions.""" |
| 36 | + with patch.object(agent_module, "get_agent_source_content", return_value="# Claude Skill"): |
| 37 | + result = runner.invoke(cli, ["agent", "show", "claude"]) |
| 38 | + |
| 39 | + assert result.exit_code == 0 |
| 40 | + assert "Claude Skill" in result.output |
| 41 | + |
| 42 | + def test_agent_show_missing_content_returns_error(self, runner): |
| 43 | + """Test error when bundled agent instructions are missing.""" |
| 44 | + with patch.object(agent_module, "get_agent_source_content", return_value=None): |
| 45 | + result = runner.invoke(cli, ["agent", "show", "codex"]) |
| 46 | + |
| 47 | + assert result.exit_code == 1 |
| 48 | + assert "not found" in result.output.lower() |
| 49 | + |
| 50 | + |
| 51 | +class TestAgentTemplates: |
| 52 | + """Tests for bundled agent template loading.""" |
| 53 | + |
| 54 | + def test_codex_template_falls_back_to_package_data(self, tmp_path): |
| 55 | + """Test that codex content falls back to packaged data outside repo root.""" |
| 56 | + with patch.object(agent_templates_module, "REPO_ROOT_AGENTS", tmp_path / "AGENTS.md"): |
| 57 | + content = agent_templates_module.get_agent_source_content("codex") |
| 58 | + |
| 59 | + assert content is not None |
| 60 | + assert "Repository Guidelines" in content |
| 61 | + |
| 62 | + def test_claude_template_reads_package_data(self): |
| 63 | + """Test that claude content reads from packaged skill data.""" |
| 64 | + content = agent_templates_module.get_agent_source_content("claude") |
| 65 | + |
| 66 | + assert content is not None |
| 67 | + assert "NotebookLM Automation" in content |
0 commit comments