o2o-plagiarism-ai/tests/test_precedent_collector.py

48 lines
1.6 KiB
Python

import json
import pytest
from scripts.collect_copyright_precedents import extract_detail, title_candidate
from scripts.validate_precedents import validate_engine_labels
def test_extract_detail_uses_primary_case_not_referenced_case():
item = {
"board_id": "1",
"title": "소설의 실질적 유사성 판단",
"registered_date": "2026-01-01",
"source_url": "https://www.copyright.or.kr/example",
}
body = """
<a class="attachment" href="download.do">대법원_2024다12345_판결서.pdf</a>
<div class="view_contents">
<p>대법원 2026. 1. 1. 선고 2024다12345 판결</p>
<p>판시사항</p><p>복제권과 실질적 유사성</p>
<p>참조판례 대법원 2012다73493 판결</p>
</div>
"""
rows = extract_detail(item, body)
assert [row["case_id"] for row in rows] == ["2024다12345"]
assert "2012다73493" not in {row["case_id"] for row in rows}
def test_title_candidate_rejects_false_keyword_substrings():
assert not title_candidate("직권파기사유로 원심판결을 파기한 사건")
assert not title_candidate("인용상표와 등록상표의 유사성 판단")
assert title_candidate("수험서의 저작물성과 실질적 유사성 판단")
def test_engine_label_validator_rejects_unmatchable_record(tmp_path):
path = tmp_path / "precedents.jsonl"
path.write_text(json.dumps({
"case_id": "2024다12345",
"legal_tags": [],
"work_types": ["literary"],
"criteria": [],
}), encoding="utf-8")
with pytest.raises(ValueError, match="법적 태그 없음"):
validate_engine_labels(path)