o2o-plagiarism-ai/tests/test_api.py

59 lines
1.7 KiB
Python

"""스모크 테스트. `pip install fastapi httpx pytest` 후 실행."""
from __future__ import annotations
from fastapi.testclient import TestClient
from app.main import app
def test_health():
with TestClient(app) as client:
resp = client.get("/v1/health")
assert resp.status_code == 200
body = resp.json()
assert body["status"] == "ok"
assert body["corpus_size"] >= 0
def test_detect_no_auth_required():
"""인증 제거 - 키 없이도 200 응답."""
with TestClient(app) as client:
resp = client.post(
"/v1/plagiarism/detect",
json={"doc_id": "x", "text": "테스트 본문"},
)
assert resp.status_code == 200
def test_detect_returns_schema():
with TestClient(app) as client:
resp = client.post(
"/v1/plagiarism/detect",
json={
"doc_id": "t-1",
"text": "어린왕자는 작은 별에서 온 소년이다. 그는 여우를 만나 길들임을 배운다.",
},
)
assert resp.status_code == 200
body = resp.json()
assert body["doc_id"] == "t-1"
assert "matches" in body
assert "extracted_elements" in body
assert "engine_version" in body
def test_batch_flow():
with TestClient(app) as client:
resp = client.post(
"/v1/plagiarism/batch",
json={
"items": [
{"doc_id": "b-1", "text": "앤 셜리는 초록 지붕 집에 입양된 소녀다."},
]
},
)
assert resp.status_code == 202
job_id = resp.json()["job_id"]
status = client.get(f"/v1/plagiarism/batch/{job_id}")
assert status.status_code == 200