From 6fe8d199a0304ea5249d0c57deb72b68b771224d Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 20 May 2026 18:37:17 -0400 Subject: [PATCH] fix(fc3b): replace FC-3a KNOWN_PLATFORMS w/ registry; drop /api/sources/platforms Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/app/api/sources.py | 5 ----- backend/app/services/source_service.py | 8 ++++---- tests/test_api_sources.py | 8 -------- tests/test_source_service.py | 8 ++++++-- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/backend/app/api/sources.py b/backend/app/api/sources.py index 8e5eb99..d5ef480 100644 --- a/backend/app/api/sources.py +++ b/backend/app/api/sources.py @@ -24,11 +24,6 @@ def _bad(error: str, *, status: int = 400, detail: str | None = None, **extra): return jsonify(body), status -@sources_bp.route("/platforms", methods=["GET"]) -async def platforms(): - return jsonify({"platforms": sorted(KNOWN_PLATFORMS)}) - - @sources_bp.route("", methods=["GET"]) async def list_sources(): artist_id_raw = request.args.get("artist_id") diff --git a/backend/app/services/source_service.py b/backend/app/services/source_service.py index 90ce41d..f5ff108 100644 --- a/backend/app/services/source_service.py +++ b/backend/app/services/source_service.py @@ -9,11 +9,11 @@ from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.asyncio import AsyncSession from ..models import Artist, Source +from .platforms import known_platform_keys -# App-level allowlist (frozenset to make accidental mutation loud). -KNOWN_PLATFORMS: frozenset[str] = frozenset({ - "patreon", "fanbox", "subscribestar", "pixiv", "deviantart", -}) +# Re-exported for back-compat with FC-3a; the registry in +# services/platforms.py is the single source of truth. +KNOWN_PLATFORMS = known_platform_keys() # --- Errors ----------------------------------------------------------------- diff --git a/tests/test_api_sources.py b/tests/test_api_sources.py index 2979230..38af037 100644 --- a/tests/test_api_sources.py +++ b/tests/test_api_sources.py @@ -25,14 +25,6 @@ async def artist(db): return a -@pytest.mark.asyncio -async def test_platforms_endpoint(client): - resp = await client.get("/api/sources/platforms") - assert resp.status_code == 200 - body = await resp.get_json() - assert "patreon" in body["platforms"] - - @pytest.mark.asyncio async def test_create_list_get_delete(client, artist): create = await client.post("/api/sources", json={ diff --git a/tests/test_source_service.py b/tests/test_source_service.py index 65e8336..aa310ef 100644 --- a/tests/test_source_service.py +++ b/tests/test_source_service.py @@ -23,8 +23,12 @@ async def _artist(db, name="Alice"): @pytest.mark.asyncio -async def test_known_platforms_contains_starter_set(db): - assert {"patreon", "fanbox", "subscribestar", "pixiv", "deviantart"} <= KNOWN_PLATFORMS +async def test_known_platforms_is_gs_six(db): + assert KNOWN_PLATFORMS == frozenset({ + "patreon", "subscribestar", "hentaifoundry", + "discord", "pixiv", "deviantart", + }) + assert "fanbox" not in KNOWN_PLATFORMS @pytest.mark.asyncio