Files
FabledCurator/tests/test_platform_lock.py
T
bvandeusen d8d8ecd78f
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 21s
CI / backend-lint-and-test (push) Successful in 28s
CI / integration (push) Failing after 3m18s
feat(subscribestar): flip dispatch to the native ingester (#893, Step 5)
SubscribeStar now downloads + verifies through the native core ingester instead
of gallery-dl — the go-live switch for milestone #71.

- download_backends: subscribestar added to NATIVE_INGESTER_PLATFORMS; a
  _NATIVE_INGESTERS registry + _resolve_native_campaign_id make _run_native_ingester
  / preview_source / verify_source_credential platform-aware. SubscribeStar's
  campaign_id IS the creator URL (no resolver); Patreon still resolves the vanity.
  preview now catches the shared NativeIngestError (covers both platforms).
- platform_lock: subscribestar serialized (one paced walk at a time).
- gallery_dl: subscribestar entry removed from PLATFORM_DEFAULTS (rule 22 — no
  fallback once native works).
- frontend SourceActions: isPatreon → isNative (patreon|subscribestar) so the
  recover/recapture actions show for subscribestar; download_service's
  cursor/mode/post_first + the preview endpoint already key on
  uses_native_ingester, so backfill/recovery/recapture/preview light up for free.
- tests: download_backends (subscribestar native), platform_lock (serialized),
  and three gallery-dl-sample tests repointed to hentaifoundry (api_credentials
  verify, gallery_dl_service skip-value, api_sources arm-no-preflight).

post_is_gated stays best-effort (can't cause junk downloads); not gating this.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 12:03:48 -04:00

37 lines
1.2 KiB
Python

"""Per-platform download concurrency cap (Redis lock)."""
import pytest
from backend.app.services.platform_lock import platform_lock
# Needs the broker (Redis) the lock lives in.
pytestmark = pytest.mark.integration
def test_non_serialized_platform_has_no_lock():
# gallery-dl platforms aren't capped — they get no lock at all.
assert platform_lock("deviantart", ttl_seconds=60) is None
assert platform_lock("hentaifoundry", ttl_seconds=60) is None
def test_subscribestar_is_serialized():
# subscribestar is a native-ingester platform now — one paced walk at a time.
lock = platform_lock("subscribestar", ttl_seconds=60)
assert lock is not None
def test_patreon_serializes_to_one_holder():
first = platform_lock("patreon", ttl_seconds=60)
assert first is not None
assert first.acquire(blocking=False) is True
try:
# A second acquirer is refused while the first holds it.
second = platform_lock("patreon", ttl_seconds=60)
assert second.acquire(blocking=False) is False
finally:
first.release()
# Once released, the platform is acquirable again.
third = platform_lock("patreon", ttl_seconds=60)
assert third.acquire(blocking=False) is True
third.release()