27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
import pytest
|
|
|
|
from review_agent.models import Conversation, FileSummaryBatch, RegulatoryReviewBatch
|
|
from review_agent.regulatory_review.storage import save_artifact
|
|
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_save_artifact_writes_file_and_records_hash(settings, tmp_path, django_user_model):
|
|
settings.MEDIA_ROOT = tmp_path
|
|
user = django_user_model.objects.create_user(username="owner", password="pass")
|
|
conversation = Conversation.objects.create(user=user, title="会话")
|
|
summary = FileSummaryBatch.objects.create(conversation=conversation, user=user, batch_no="FS-OK")
|
|
batch = RegulatoryReviewBatch.objects.create(
|
|
conversation=conversation,
|
|
user=user,
|
|
source_summary_batch=summary,
|
|
batch_no="RR-ART",
|
|
)
|
|
|
|
artifact = save_artifact(batch, name="raw.json", content='{"ok": true}', artifact_type="json")
|
|
|
|
assert artifact.content_hash
|
|
assert artifact.storage_path.endswith("raw.json")
|
|
assert (tmp_path / "regulatory_review" / "work" / "RR-ART" / "raw.json").exists()
|