63 lines
2.2 KiB
Python
63 lines
2.2 KiB
Python
import pytest
|
|
from pathlib import Path
|
|
from src import aggregate
|
|
|
|
def test_auto_aggregate_skip(tmp_path):
|
|
# Create some test files
|
|
f1 = tmp_path / "file1.txt"
|
|
f1.write_text("content1")
|
|
f2 = tmp_path / "file2.txt"
|
|
f2.write_text("content2")
|
|
|
|
files = [
|
|
{"path": "file1.txt", "auto_aggregate": True},
|
|
{"path": "file2.txt", "auto_aggregate": False},
|
|
]
|
|
|
|
items = aggregate.build_file_items(tmp_path, files)
|
|
|
|
# Test _build_files_section_from_items
|
|
section = aggregate._build_files_section_from_items(items)
|
|
assert "file1.txt" in section
|
|
assert "file2.txt" not in section
|
|
|
|
# Test build_tier1_context
|
|
t1 = aggregate.build_tier1_context(items, tmp_path, [], [])
|
|
assert "file1.txt" in t1
|
|
assert "file2.txt" not in t1
|
|
|
|
# Test build_tier3_context
|
|
t3 = aggregate.build_tier3_context(items, tmp_path, [], [], [])
|
|
assert "file1.txt" in t3
|
|
assert "file2.txt" not in t3
|
|
|
|
def test_force_full(tmp_path):
|
|
# Create a python file that would normally be skeletonized in Tier 3
|
|
py_file = tmp_path / "script.py"
|
|
py_file.write_text("def hello():\n print('world')\n")
|
|
|
|
# Tier 3 normally skeletonizes non-focus python files
|
|
items = aggregate.build_file_items(tmp_path, [{"path": "script.py", "force_full": True}])
|
|
|
|
# Test build_tier3_context
|
|
t3 = aggregate.build_tier3_context(items, tmp_path, [], [], [])
|
|
assert "print('world')" in t3 # Full content present
|
|
|
|
# Compare with non-force_full
|
|
items2 = aggregate.build_file_items(tmp_path, [{"path": "script.py", "force_full": False}])
|
|
t3_2 = aggregate.build_tier3_context(items2, tmp_path, [], [], [])
|
|
assert "print('world')" not in t3_2 # Skeletonized
|
|
|
|
# Tier 1 normally summarizes non-core files
|
|
txt_file = tmp_path / "other.txt"
|
|
txt_file.write_text("line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10")
|
|
|
|
items3 = aggregate.build_file_items(tmp_path, [{"path": "other.txt", "force_full": True}])
|
|
t1 = aggregate.build_tier1_context(items3, tmp_path, [], [])
|
|
assert "line10" in t1 # Full content present
|
|
|
|
items4 = aggregate.build_file_items(tmp_path, [{"path": "other.txt", "force_full": False}])
|
|
t1_2 = aggregate.build_tier1_context(items4, tmp_path, [], [])
|
|
# Generic summary for .txt shows first 8 lines
|
|
assert "line10" not in t1_2
|