1
0
Fork 0
Code Issues Pull requests Projects Releases 2 Packages Wiki Activity Actions Pages

Keep reference manifests parser-free

This commit is contained in:
Andraxion 2026-07-29 14:52:05 -04:00
parent 58c0196be5
commit 9cd7c4e424
4 changed files with 368 additions and 67 deletions

View file

@ -5,7 +5,9 @@ import tempfile
import unittest
from pathlib import Path
from typing import cast
from unittest import mock
import docforge.adapters.python as python_adapter
from docforge.adapter_sdk import (
AdapterProject,
AdapterSource,
@ -137,10 +139,17 @@ class PythonReferenceAdapterTests(unittest.TestCase):
)
adapter.extracted_paths.clear()
warm = index.build()
original_parse = python_adapter.ast.parse
with mock.patch.object(
python_adapter.ast,
"parse",
wraps=original_parse,
) as parsed:
warm = index.build()
self.assertEqual(4, self.build_metrics(warm)["cache_hits"])
self.assertEqual(0, self.build_metrics(warm)["reparsed_sources"])
self.assertEqual([], adapter.extracted_paths)
parsed.assert_not_called()
shared = root / "src" / "sample" / "shared.py"
shared.write_text(
@ -150,8 +159,14 @@ class PythonReferenceAdapterTests(unittest.TestCase):
encoding="utf-8",
)
adapter.extracted_paths.clear()
changed = index.build()
with mock.patch.object(
python_adapter.ast,
"parse",
wraps=original_parse,
) as parsed:
changed = index.build()
self.assertEqual(4, self.build_metrics(changed)["invalidated_sources"])
self.assertGreater(parsed.call_count, 0)
self.assertEqual(
[
"src/sample/__init__.py",