MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / test_handles_bad_json

Method test_handles_bad_json

tests/test_compiler.py:1224–1244  ·  view source on GitHub ↗
(self, tmp_path)

Source from the content-addressed store, hash-verified

1222
1223 @pytest.mark.asyncio
1224 async def test_handles_bad_json(self, tmp_path):
1225 wiki = tmp_path / "wiki"
1226 (wiki / "sources").mkdir(parents=True)
1227 (wiki / "summaries").mkdir(parents=True)
1228 (wiki / "index.md").write_text(
1229 "# Index\n\n## Documents\n\n## Concepts\n",
1230 encoding="utf-8",
1231 )
1232 source_path = wiki / "sources" / "doc.md"
1233 source_path.write_text("Content", encoding="utf-8")
1234 (tmp_path / ".openkb").mkdir()
1235
1236 with patch("openkb.agent.compiler.litellm") as mock_litellm:
1237 mock_litellm.completion = MagicMock(
1238 side_effect=_mock_completion(["Plain summary text", "not valid json"])
1239 )
1240 # Should not raise
1241 await compile_short_doc("doc", source_path, tmp_path, "gpt-4o-mini")
1242
1243 # Summary should still be written
1244 assert (wiki / "summaries" / "doc.md").exists()
1245
1246
1247class TestCompileShortDocFallbacks:

Callers

nothing calls this directly

Calls 2

compile_short_docFunction · 0.90
_mock_completionFunction · 0.85

Tested by

no test coverage detected