Files
FabledCurator/tests/test_api_series.py
T
bvandeusen def967a1a8 refactor(dry-S1): hoist app/client test fixtures into conftest
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>
2026-05-28 11:33:05 -04:00

61 lines
1.7 KiB
Python

import pytest
pytestmark = pytest.mark.integration
async def _series(client, name="Vol"):
r = await client.post("/api/tags", json={"name": name, "kind": "series"})
return (await r.get_json())["id"]
@pytest.mark.asyncio
async def test_pages_404_for_non_series(client):
r = await client.post("/api/tags", json={"name": "g", "kind": "general"})
gid = (await r.get_json())["id"]
resp = await client.get(f"/api/series/{gid}/pages")
assert resp.status_code == 404
@pytest.mark.asyncio
async def test_pages_empty_shape(client):
sid = await _series(client, "Empty")
resp = await client.get(f"/api/series/{sid}/pages")
assert resp.status_code == 200
body = await resp.get_json()
assert body["series"]["id"] == sid
assert body["pages"] == []
@pytest.mark.asyncio
async def test_add_requires_ids(client):
sid = await _series(client, "NoIds")
resp = await client.post(f"/api/series/{sid}/pages", json={})
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_add_over_cap_400(client):
sid = await _series(client, "Cap")
resp = await client.post(
f"/api/series/{sid}/pages",
json={"image_ids": list(range(1, 502))},
)
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_reorder_mismatch_400(client):
sid = await _series(client, "Re")
resp = await client.post(
f"/api/series/{sid}/reorder", json={"image_ids": [1, 2, 3]}
)
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_cover_requires_image_id(client):
sid = await _series(client, "Cov")
resp = await client.post(f"/api/series/{sid}/cover", json={})
assert resp.status_code == 400