diff --git a/tests/test_patreon_client.py b/tests/test_patreon_client.py index 3ef504a..02bd328 100644 --- a/tests/test_patreon_client.py +++ b/tests/test_patreon_client.py @@ -68,24 +68,20 @@ def test_extract_gallery_dedups_image_large(client, response): assert all(m.post_id == "1001" for m in items) -def test_extract_attachment_and_postfile(client, response): +def test_extract_attachment_postfile_same_file_collapses(client, response): index = client._transform(response) post = _post_by_id(response, "1002") items = client.extract_media(post, index) - by_kind = {m.kind: m for m in items} - # attachments_media → "attachments", plus the post_file → "postfile". - assert set(by_kind) == {"attachments", "postfile"} - assert by_kind["attachments"].filename == "bonus-pack.zip" - assert by_kind["attachments"].filehash == "c" * 32 - assert by_kind["postfile"].filename == "bonus-pack.zip" - # postfile URL also carries the same hash, but they're different kinds in - # different relationships; both are kept because dedup is by filehash and - # the attachment is encountered first... assert the post_file collapsed. - # (attachments resolved before postfile, same hash → postfile dropped.) - # So only ONE survives with that hash: - surviving_c = [m for m in items if m.filehash == "c" * 32] - assert len(surviving_c) == 1 + # The attachment (attachments_media 9003) and the post_file are the SAME + # zip — both carry filehash c…. attachments resolve before postfile, so the + # postfile collapses into the attachment by filehash → exactly one survives. + # (postfile-as-a-kind is exercised separately by the video post test.) + assert len(items) == 1 + item = items[0] + assert item.kind == "attachments" + assert item.filename == "bonus-pack.zip" + assert item.filehash == "c" * 32 def test_extract_inline_content_img(client, response):