feat(file-summary): 实现文件处理技能链路
This commit is contained in:
24
tests/test_file_summary_inventory.py
Normal file
24
tests/test_file_summary_inventory.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from review_agent.file_summary.services.inventory import scan_files_to_items
|
||||
from review_agent.models import Conversation, FileSummaryBatch, FileSummaryItem
|
||||
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_scan_files_to_items_preserves_relative_paths(tmp_path, django_user_model):
|
||||
root = tmp_path / "work"
|
||||
(root / "a").mkdir(parents=True)
|
||||
(root / "a" / "one.pdf").write_bytes(b"pdf")
|
||||
(root / "two.txt").write_text("x", encoding="utf-8")
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
conversation = Conversation.objects.create(user=user, title="会话")
|
||||
batch = FileSummaryBatch.objects.create(conversation=conversation, user=user, batch_no="FS-I")
|
||||
|
||||
items = scan_files_to_items(batch=batch, roots=[root])
|
||||
|
||||
assert [item.relative_path for item in items] == ["a/one.pdf", "two.txt"]
|
||||
assert FileSummaryItem.objects.filter(batch=batch).count() == 2
|
||||
assert items[0].statistics_status == FileSummaryItem.StatisticsStatus.SKIPPED
|
||||
Reference in New Issue
Block a user