feat(mma): Integrate AST skeleton extraction into Tier 3 context build
This commit is contained in:
@@ -24,13 +24,45 @@ def test_build_tier2_context_exists():
|
||||
result = build_tier2_context(file_items, Path("."), [], history)
|
||||
assert "Other content" in result
|
||||
|
||||
def test_build_tier3_context_ast_skeleton(monkeypatch):
|
||||
from unittest.mock import MagicMock
|
||||
import aggregate
|
||||
import file_cache
|
||||
|
||||
# Mock ASTParser
|
||||
mock_parser_instance = MagicMock()
|
||||
mock_parser_instance.get_skeleton.return_value = "def other():\n ..."
|
||||
mock_parser_class = MagicMock(return_value=mock_parser_instance)
|
||||
|
||||
# Mock file_cache.ASTParser in aggregate module
|
||||
monkeypatch.setattr("aggregate.ASTParser", mock_parser_class)
|
||||
|
||||
file_items = [
|
||||
{"path": Path("other.py"), "entry": "other.py", "content": "def other():\n pass", "error": False}
|
||||
]
|
||||
history = []
|
||||
|
||||
# New behavior check: it should use ASTParser for .py files not in focus
|
||||
result = build_tier3_context(file_items, Path("."), [], history, focus_files=[])
|
||||
|
||||
assert "def other():" in result
|
||||
assert "..." in result
|
||||
assert "Python" not in result # summarize.py output should not be there if AST skeleton is used
|
||||
mock_parser_class.assert_called_once_with("python")
|
||||
mock_parser_instance.get_skeleton.assert_called_once_with("def other():\n pass")
|
||||
|
||||
def test_build_tier3_context_exists():
|
||||
file_items = [
|
||||
{"path": Path("focus.py"), "entry": "focus.py", "content": "Focus content", "error": False},
|
||||
{"path": Path("other.py"), "entry": "other.py", "content": "Other content", "error": False}
|
||||
{"path": Path("focus.py"), "entry": "focus.py", "content": "def focus():\n pass", "error": False},
|
||||
{"path": Path("other.py"), "entry": "other.py", "content": "def other():\n pass", "error": False}
|
||||
]
|
||||
history = ["User: hello"]
|
||||
result = build_tier3_context(file_items, Path("."), [], history, focus_files=["focus.py"])
|
||||
|
||||
assert "Focus content" in result
|
||||
assert "Other content" not in result
|
||||
assert "def focus():" in result
|
||||
assert "pass" in result
|
||||
# other.py should have skeletonized content, not full "pass" (if get_skeleton works)
|
||||
# However, for a simple "pass", the skeleton might be the same or similar.
|
||||
# Let's check for the header
|
||||
assert "other.py" in result
|
||||
assert "AST Skeleton" in result
|
||||
|
||||
Reference in New Issue
Block a user