test(pixiv): fix downloader tests — skip validation on stub bytes, no media extraction in post-record tests
The stub payload is PNG bytes regardless of target extension, so the real validator quarantined the .jpg cases; and extracting the ugoira work hit the API seam of a fake session with no .post. Validation/quarantine plumbing stays covered by the Patreon downloader tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDgx8bQS5YrGRK76v8HUnM
This commit is contained in:
@@ -67,9 +67,24 @@ def _post_and_media(work_id):
|
||||
raise AssertionError(f"no work {work_id} in fixture")
|
||||
|
||||
|
||||
def _post_only(work_id):
|
||||
"""Normalized post WITHOUT media extraction — the write_post_record tests
|
||||
don't need media, and extracting an ugoira would hit the API seam."""
|
||||
page = json.loads(_FIXTURE.read_text())
|
||||
for work in page["illusts"]:
|
||||
if work["id"] == work_id:
|
||||
return _client()._normalize(work)
|
||||
raise AssertionError(f"no work {work_id} in fixture")
|
||||
|
||||
|
||||
def _downloader(tmp_path, session=None):
|
||||
# validate=False: the stub payload is PNG bytes regardless of the target
|
||||
# extension, so real validation would quarantine the .jpg cases. The
|
||||
# validate/quarantine plumbing is BaseNativeDownloader's, covered by the
|
||||
# Patreon downloader tests.
|
||||
return PixivDownloader(
|
||||
tmp_path, session=session if session is not None else _FakeSession(),
|
||||
tmp_path, validate=False,
|
||||
session=session if session is not None else _FakeSession(),
|
||||
)
|
||||
|
||||
|
||||
@@ -188,7 +203,7 @@ def test_own_session_carries_app_referer(tmp_path):
|
||||
|
||||
|
||||
def test_write_post_record_enriched(tmp_path):
|
||||
post, _ = _post_and_media(111)
|
||||
post = _post_only(111)
|
||||
dl = _downloader(tmp_path)
|
||||
outcome = dl.write_post_record(post, "artist-a")
|
||||
|
||||
@@ -219,7 +234,7 @@ def test_write_post_record_enriched(tmp_path):
|
||||
|
||||
|
||||
def test_write_post_record_rating_r18(tmp_path):
|
||||
post, _ = _post_and_media(222)
|
||||
post = _post_only(222)
|
||||
dl = _downloader(tmp_path)
|
||||
outcome = dl.write_post_record(post, "artist-a")
|
||||
data = json.loads(outcome.path.read_text())
|
||||
@@ -228,7 +243,7 @@ def test_write_post_record_rating_r18(tmp_path):
|
||||
|
||||
|
||||
def test_write_post_record_includes_ugoira_frames(tmp_path):
|
||||
post, _ = _post_and_media(333)
|
||||
post = _post_only(333)
|
||||
frames = [{"file": "000000.jpg", "delay": 90}]
|
||||
post["_work"]["_ugoira_frames"] = frames
|
||||
dl = _downloader(tmp_path)
|
||||
|
||||
Reference in New Issue
Block a user