fix(tags): invalid 'copyright' kind 500 — KINDS uses real enum 'fandom'; directory 400s on bad kind
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,3 +28,22 @@ async def test_directory_endpoint(client, db):
|
||||
async def test_directory_bad_limit(client):
|
||||
resp = await client.get("/api/tags/directory?limit=nan")
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_directory_invalid_kind_is_400_not_500(client):
|
||||
# 'copyright' is not a TagKind member; the route must reject it
|
||||
# cleanly (400) instead of letting the enum cast 500.
|
||||
resp = await client.get("/api/tags/directory?kind=copyright")
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_directory_valid_kind_ok(client, db):
|
||||
db.add(Tag(name="a_fandom", kind=TagKind.fandom))
|
||||
await db.flush()
|
||||
await db.commit()
|
||||
resp = await client.get("/api/tags/directory?kind=fandom&limit=10")
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
assert any(c["name"] == "a_fandom" for c in body["cards"])
|
||||
|
||||
Reference in New Issue
Block a user