Skip to content

Commit ef9e83f

Browse files
committed
update tests
1 parent 7bb1d6d commit ef9e83f

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

tests/test_cli.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,86 @@ def test_claude_code_agent_tools_injected(self, runner, tmp_path):
743743
assert "file_timeline" in agent_py
744744
assert "my_preferences" in agent_py
745745

746+
def test_claude_code_config_settings_fields(self, runner, tmp_path):
747+
"""Generated config.py should have claude_code_* Settings fields."""
748+
out = tmp_path / "cc-config"
749+
result = runner.invoke(main, [
750+
"cc-config",
751+
"--domain", "software-engineering",
752+
"--framework", "pydanticai",
753+
"--connector", "claude-code",
754+
"--output-dir", str(out),
755+
])
756+
assert result.exit_code == 0, result.output
757+
config_py = (out / "backend" / "app" / "config.py").read_text()
758+
assert "claude_code_scope" in config_py
759+
assert "claude_code_max_sessions" in config_py
760+
assert "claude_code_content_mode" in config_py
761+
assert "claude_code_base_path" in config_py
762+
763+
def test_claude_code_import_data_dict_access(self, runner, tmp_path):
764+
"""Generated import_data.py should use dict access, not attribute access."""
765+
out = tmp_path / "cc-dict"
766+
result = runner.invoke(main, [
767+
"cc-dict",
768+
"--domain", "software-engineering",
769+
"--framework", "pydanticai",
770+
"--connector", "claude-code",
771+
"--output-dir", str(out),
772+
])
773+
assert result.exit_code == 0, result.output
774+
import_data = (out / "backend" / "scripts" / "import_data.py").read_text()
775+
assert 'data["entities"]' in import_data
776+
assert "data.entities" not in import_data
777+
778+
def test_claude_code_connector_entity_types(self, runner, tmp_path):
779+
"""Generated connector should extract all entity types including Decision/Preference."""
780+
out = tmp_path / "cc-entities"
781+
result = runner.invoke(main, [
782+
"cc-entities",
783+
"--domain", "software-engineering",
784+
"--framework", "pydanticai",
785+
"--connector", "claude-code",
786+
"--output-dir", str(out),
787+
])
788+
assert result.exit_code == 0, result.output
789+
connector = (out / "backend" / "app" / "connectors" / "claude_code_connector.py").read_text()
790+
for entity in ["GitBranch", "Error", "Decision", "Preference", "Alternative"]:
791+
assert entity in connector, f"Missing entity type: {entity}"
792+
for rel in ["ON_BRANCH", "ENCOUNTERED_ERROR", "MADE_DECISION", "CHOSE", "REJECTED",
793+
"NEXT", "PRECEDED_BY", "USED_TOOL", "EXPRESSES_PREFERENCE"]:
794+
assert rel in connector, f"Missing relationship type: {rel}"
795+
796+
def test_claude_code_connector_has_redaction(self, runner, tmp_path):
797+
"""Generated connector should include secret redaction."""
798+
out = tmp_path / "cc-redact"
799+
result = runner.invoke(main, [
800+
"cc-redact",
801+
"--domain", "software-engineering",
802+
"--framework", "pydanticai",
803+
"--connector", "claude-code",
804+
"--output-dir", str(out),
805+
])
806+
assert result.exit_code == 0, result.output
807+
connector = (out / "backend" / "app" / "connectors" / "claude_code_connector.py").read_text()
808+
assert "REDACTED" in connector
809+
assert "_SECRET_PATTERNS" in connector
810+
811+
def test_claude_code_scenarios_override(self, runner, tmp_path):
812+
"""Claude Code connector should replace generic SE scenarios with session-specific ones."""
813+
out = tmp_path / "cc-scenarios"
814+
result = runner.invoke(main, [
815+
"cc-scenarios",
816+
"--domain", "software-engineering",
817+
"--framework", "pydanticai",
818+
"--connector", "claude-code",
819+
"--output-dir", str(out),
820+
])
821+
assert result.exit_code == 0, result.output
822+
frontend_config = (out / "frontend" / "lib" / "config.ts").read_text()
823+
assert "Session Intelligence" in frontend_config
824+
assert "pull requests" not in frontend_config.lower()
825+
746826
def test_with_mcp_flag(self, runner, tmp_path):
747827
"""Verify --with-mcp generates MCP config files."""
748828
out = tmp_path / "my-app"

tests/test_renderer.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,35 @@ def test_config_py_has_session_strategy(self, financial_config, tmp_output):
524524
config_py = (tmp_output / "backend" / "app" / "config.py").read_text()
525525
assert "session_strategy" in config_py
526526

527+
def test_claude_code_scenarios_override_generic(self, tmp_output):
528+
"""When claude-code connector is active, demo scenarios should be replaced."""
529+
config = ProjectConfig(
530+
project_name="cc-test",
531+
domain="software-engineering",
532+
framework="pydanticai",
533+
saas_connectors=["claude-code"],
534+
)
535+
ontology = load_domain(config.domain)
536+
renderer = ProjectRenderer(config, ontology)
537+
ctx = renderer._context()
538+
539+
scenario_names = [s["name"] for s in ctx["demo_scenarios"]]
540+
assert "Session Intelligence" in scenario_names
541+
# Should NOT contain generic SE scenarios
542+
prompts = [p for s in ctx["demo_scenarios"] for p in s["prompts"]]
543+
assert not any("pull request" in p.lower() for p in prompts)
544+
545+
def test_no_scenario_override_without_connector(self, financial_config, tmp_output):
546+
"""Without claude-code connector, domain scenarios should be used as-is."""
547+
ontology = load_domain(financial_config.domain)
548+
renderer = ProjectRenderer(financial_config, ontology)
549+
ctx = renderer._context()
550+
551+
# Should use the domain's own scenarios
552+
assert len(ctx["demo_scenarios"]) > 0
553+
scenario_names = [s["name"] for s in ctx["demo_scenarios"]]
554+
assert "Session Intelligence" not in scenario_names
555+
527556

528557
class TestAllFrameworksRender:
529558
"""Verify every agent framework template renders and compiles."""

0 commit comments

Comments
 (0)