fc3d: api_sources tests cover consecutive_failures + next_check_at fields
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -130,3 +130,44 @@ async def test_patch_404(client):
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_404(client):
|
||||
assert (await client.delete("/api/sources/99999")).status_code == 404
|
||||
|
||||
|
||||
# --- FC-3d: SourceRecord surfaces consecutive_failures + next_check_at ----
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_response_includes_fc3d_fields(client, artist):
|
||||
resp = await client.post("/api/sources", json={
|
||||
"artist_id": artist.id, "platform": "patreon",
|
||||
"url": "https://patreon.com/alice-fc3d-new",
|
||||
})
|
||||
assert resp.status_code == 201
|
||||
body = await resp.get_json()
|
||||
assert body["consecutive_failures"] == 0
|
||||
assert body["next_check_at"] is None # never checked yet
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_derives_next_check_at_when_last_checked_set(
|
||||
client, artist, db,
|
||||
):
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from backend.app.models import Source
|
||||
|
||||
src = Source(
|
||||
artist_id=artist.id, platform="patreon",
|
||||
url="https://patreon.com/alice-fc3d-checked", enabled=True,
|
||||
consecutive_failures=0,
|
||||
last_checked_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(src)
|
||||
await db.commit()
|
||||
|
||||
resp = await client.get("/api/sources")
|
||||
body = await resp.get_json()
|
||||
target = next(
|
||||
r for r in body if r["url"] == "https://patreon.com/alice-fc3d-checked"
|
||||
)
|
||||
assert target["next_check_at"] is not None
|
||||
assert "T" in target["next_check_at"] # ISO 8601
|
||||
|
||||
Reference in New Issue
Block a user