|
13 | 13 | COCOSEARCH_MCP_TOOL_PERMISSIONS, |
14 | 14 | COCOSEARCH_NUDGE_MARKER, |
15 | 15 | CONFIG_TEMPLATE, |
| 16 | + CocoSearchConfig, |
16 | 17 | ConfigError, |
17 | 18 | check_claude_plugin_installed, |
18 | 19 | generate_agents_md_routing, |
@@ -67,6 +68,59 @@ def test_config_template_contains_linked_indexes_comment(): |
67 | 68 | assert "common-utils" in CONFIG_TEMPLATE |
68 | 69 |
|
69 | 70 |
|
| 71 | +def _uncomment_block(marker: str) -> dict: |
| 72 | + """Uncomment one '# ' level of the CONFIG_TEMPLATE block beginning at `marker` |
| 73 | + (a fully-commented section like '# controller:') up to its trailing blank |
| 74 | + line, then parse it as YAML. Double-commented sub-fields stay commented.""" |
| 75 | + lines = CONFIG_TEMPLATE.splitlines() |
| 76 | + start = next(i for i, ln in enumerate(lines) if ln.strip() == marker) |
| 77 | + block = [] |
| 78 | + for ln in lines[start:]: |
| 79 | + if not ln.startswith("#"): # blank line ends the block |
| 80 | + break |
| 81 | + block.append(ln[2:] if ln.startswith("# ") else ln) |
| 82 | + return yaml.safe_load("\n".join(block)) |
| 83 | + |
| 84 | + |
| 85 | +def test_config_template_contains_controller_comment(): |
| 86 | + """Test that CONFIG_TEMPLATE documents the optional query-rewrite controller.""" |
| 87 | + assert "# controller:" in CONFIG_TEMPLATE |
| 88 | + assert "enabled: false" in CONFIG_TEMPLATE |
| 89 | + assert "provider: ollama" in CONFIG_TEMPLATE |
| 90 | + assert "qwen2.5:3b" in CONFIG_TEMPLATE |
| 91 | + |
| 92 | + |
| 93 | +def test_config_template_controller_example_is_schema_valid(): |
| 94 | + """The commented controller example must validate against ControllerSection |
| 95 | + once uncommented — guards the docs from drifting out of sync with the schema.""" |
| 96 | + config = CocoSearchConfig(**_uncomment_block("# controller:")) |
| 97 | + assert config.controller.enabled is False |
| 98 | + assert config.controller.provider == "ollama" |
| 99 | + assert config.controller.model == "qwen2.5:3b" |
| 100 | + |
| 101 | + |
| 102 | +def test_config_template_documents_embedding_provider(): |
| 103 | + """Test that CONFIG_TEMPLATE documents the multi-provider embedding options.""" |
| 104 | + assert "provider: ollama" in CONFIG_TEMPLATE |
| 105 | + assert "baseUrl" in CONFIG_TEMPLATE |
| 106 | + assert "openrouter" in CONFIG_TEMPLATE |
| 107 | + assert "COCOSEARCH_EMBEDDING_API_KEY" in CONFIG_TEMPLATE |
| 108 | + |
| 109 | + |
| 110 | +def test_config_template_contains_logging_comment(): |
| 111 | + """Test that CONFIG_TEMPLATE documents the optional file logging toggle.""" |
| 112 | + assert "# logging:" in CONFIG_TEMPLATE |
| 113 | + assert "file: false" in CONFIG_TEMPLATE |
| 114 | + assert "COCOSEARCH_LOG_FILE" in CONFIG_TEMPLATE |
| 115 | + |
| 116 | + |
| 117 | +def test_config_template_logging_example_is_schema_valid(): |
| 118 | + """The commented logging example must validate against LoggingSection once |
| 119 | + uncommented — guards the docs from drifting out of sync with the schema.""" |
| 120 | + config = CocoSearchConfig(**_uncomment_block("# logging:")) |
| 121 | + assert config.logging.file is False |
| 122 | + |
| 123 | + |
70 | 124 | class TestClaudeMdRouting: |
71 | 125 | """Tests for generate_claude_md_routing.""" |
72 | 126 |
|
|
0 commit comments