42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from app.main import app
|
|
|
|
|
|
def test_precedent_api_lists_full_engine_corpus_with_pagination():
|
|
with TestClient(app) as client:
|
|
response = client.get("/v1/precedents?limit=10")
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["loaded_total"] == 545
|
|
assert body["total"] == 545
|
|
assert body["graded_total"] == 57
|
|
assert len(body["items"]) == 10
|
|
assert {
|
|
"case_id", "title", "source_url", "work_types", "legal_tags",
|
|
"criteria", "grade", "holding_excerpt",
|
|
} == set(body["items"][0])
|
|
|
|
|
|
def test_precedent_api_search_and_normalized_software_type():
|
|
with TestClient(app) as client:
|
|
response = client.get(
|
|
"/v1/precedents",
|
|
params={"q": "95가합11403", "work_type": "software"},
|
|
)
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["total"] == 1
|
|
assert body["items"][0]["case_id"] == "95가합11403"
|
|
assert body["items"][0]["work_types"] == ["software"]
|
|
|
|
|
|
def test_precedent_api_filters_review_status():
|
|
with TestClient(app) as client:
|
|
graded = client.get("/v1/precedents?grade=A&limit=100").json()
|
|
unreviewed = client.get("/v1/precedents?grade=unreviewed&limit=1").json()
|
|
assert graded["total"] == 24
|
|
assert all(item["grade"] == "A" for item in graded["items"])
|
|
assert unreviewed["total"] == 488
|
|
assert unreviewed["items"][0]["grade"] is None
|