feat(fc3b): platforms.py — GS-6 registry (single source of truth)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
from backend.app.services.platforms import (
|
||||
PLATFORMS,
|
||||
PlatformInfo,
|
||||
auth_type_for,
|
||||
known_platform_keys,
|
||||
to_dict,
|
||||
)
|
||||
|
||||
|
||||
def test_known_platform_keys_is_gs_six():
|
||||
assert known_platform_keys() == frozenset({
|
||||
"patreon", "subscribestar", "hentaifoundry",
|
||||
"discord", "pixiv", "deviantart",
|
||||
})
|
||||
|
||||
|
||||
def test_fanbox_not_in_registry():
|
||||
# Sanity check — FC-3a added 'fanbox' by mistake; it's not a GS platform.
|
||||
assert "fanbox" not in PLATFORMS
|
||||
|
||||
|
||||
def test_auth_type_for_known_and_unknown():
|
||||
assert auth_type_for("patreon") == "cookies"
|
||||
assert auth_type_for("discord") == "token"
|
||||
assert auth_type_for("nope") is None
|
||||
|
||||
|
||||
def test_each_platform_has_required_fields():
|
||||
for key, info in PLATFORMS.items():
|
||||
assert isinstance(info, PlatformInfo)
|
||||
assert info.key == key
|
||||
assert info.name
|
||||
assert info.description
|
||||
assert info.auth_type in ("cookies", "token")
|
||||
assert isinstance(info.requires_auth, bool)
|
||||
re.compile(info.url_pattern) # valid regex
|
||||
assert info.url_examples
|
||||
assert isinstance(info.default_config, dict)
|
||||
|
||||
|
||||
def test_to_dict_round_trip():
|
||||
d = to_dict(PLATFORMS["patreon"])
|
||||
assert d["key"] == "patreon"
|
||||
assert d["auth_type"] == "cookies"
|
||||
assert d["default_config"]["sleep"] == 3.0
|
||||
assert "url_examples" in d
|
||||
Reference in New Issue
Block a user