Files
FabledCurator/tests/test_api_artist.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

54 lines
1.4 KiB
Python

import pytest
from backend.app.models import Artist
pytestmark = pytest.mark.integration
@pytest.mark.asyncio
async def test_artist_404(client):
resp = await client.get("/api/artist/nope")
assert resp.status_code == 404
@pytest.mark.asyncio
async def test_artist_overview_ok(client, db):
db.add(Artist(name="Mira", slug="mira"))
await db.flush()
await db.commit()
resp = await client.get("/api/artist/mira")
assert resp.status_code == 200
body = await resp.get_json()
assert body["name"] == "Mira"
assert body["image_count"] == 0
assert body["post_count"] == 0
@pytest.mark.asyncio
async def test_artist_overview_post_count(client, db):
from backend.app.models import Post, Source
a = Artist(name="Lyra", slug="lyra")
db.add(a)
await db.flush()
s = Source(
artist_id=a.id, platform="patreon",
url="https://patreon.com/cw/lyra", enabled=True,
)
db.add(s)
await db.flush()
db.add(Post(source_id=s.id, external_post_id="p1"))
db.add(Post(source_id=s.id, external_post_id="p2"))
await db.flush()
await db.commit()
resp = await client.get("/api/artist/lyra")
assert resp.status_code == 200
body = await resp.get_json()
assert body["post_count"] == 2
@pytest.mark.asyncio
async def test_artist_images_404(client):
resp = await client.get("/api/artist/nope/images")
assert resp.status_code == 404