def967a1a8
Removed the app/client fixtures duplicated across 36 test files (two variants: separate app + client(app), and a self-contained client() that called create_app inline) and the now-unused create_app imports. Both fixtures now live once in conftest.py. test_suggestions_bulk keeps its import (builds the app inline in two tests); test_health drops its local client + unused pytest_asyncio. Net -415 lines. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import pytest
|
|
|
|
from backend.app.models import TagAllowlist, TagKind
|
|
from backend.app.services.tag_service import TagService
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_and_patch_and_delete(client, db):
|
|
tag = await TagService(db).find_or_create("AL", TagKind.character)
|
|
db.add(TagAllowlist(tag_id=tag.id, min_confidence=0.95))
|
|
await db.commit()
|
|
|
|
resp = await client.get("/api/allowlist")
|
|
assert resp.status_code == 200
|
|
assert any(r["tag_id"] == tag.id for r in await resp.get_json())
|
|
|
|
resp = await client.patch(
|
|
f"/api/tags/{tag.id}/allowlist", json={"min_confidence": 0.80}
|
|
)
|
|
assert resp.status_code == 204
|
|
|
|
resp = await client.get(f"/api/tags/{tag.id}/allowlist")
|
|
assert (await resp.get_json())["min_confidence"] == pytest.approx(0.80)
|
|
|
|
resp = await client.delete(f"/api/tags/{tag.id}/allowlist")
|
|
assert resp.status_code == 204
|
|
resp = await client.get(f"/api/tags/{tag.id}/allowlist")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_patch_rejects_out_of_range(client, db):
|
|
tag = await TagService(db).find_or_create("AL2", TagKind.character)
|
|
db.add(TagAllowlist(tag_id=tag.id))
|
|
await db.commit()
|
|
resp = await client.patch(
|
|
f"/api/tags/{tag.id}/allowlist", json={"min_confidence": 1.5}
|
|
)
|
|
assert resp.status_code == 400
|