(self, tmp_path)
| 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 | |
| 1247 | class TestCompileShortDocFallbacks: |
nothing calls this directly
no test coverage detected