Files
romm/backend/tests/utils/test_platform_slugs.py
Sam Dornan 552ac3a393 fix(platforms): share provider entries across duplicate platform slugs (#5359)
* fix(platforms): share provider entries across duplicate slugs and rename system-32

Three consoles have two RomM slugs, each used by different providers, so a
library folder only matched the providers that knew its spelling:
vc-4000 / interton-vc-4000, apple-pippin / pippin and tandy-vis / vis.
DUPLICATE_PLATFORM_SLUGS lists them once, and fill_duplicate_slugs gives
each slug the other's entry in every provider table. pippin and
interton-vc-4000 now get an IGDB platform id, and IGDB's family override
also applies to a listed duplicate so both VC 4000 slugs stay in the
Interton family.

The system-32 slug mapped to Namco System 22 in ScreenScraper and
LaunchBox, easy to confuse with Sega System 32 (system32). It is now
namco-system-22. Folders and config bindings named system-32 still
resolve to it, and migration 0154 renames existing platform rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

* fix(platforms): resolve bindings to a renamed slug back to their folder

resolve_platform_slug already maps a binding to system-32 onto
namco-system-22, but resolve_fs_slug compared the raw binding with the
new slug, so a moved folder bound to the old slug was never found.
Both now go through the same renamed-slug lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

* fix(platforms): drop the system-32 slug backfill migration

Every scan resolves a platform's slug from its folder again, so the next
scan renames system-32 rows through the renamed-slug alias without a
migration, as the backend guide asks for normalizations the parser now
handles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

* chore(platforms): reword two comments so the product isn't the actor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

* revert(platforms): leave system-32 to the arcade slug split

rommapp/romm#5273 retires system-32 as an alias of arcade and resolves
aliases in config bindings in both directions, which covers what the
namco-system-22 rename and the renamed-slug lookup did here. This PR now
only shares provider entries across duplicate slugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:28:30 -05:00

52 lines
1.8 KiB
Python

import pytest
from adapters.services.igdb import IGDB_PLATFORM_LIST
from adapters.services.rahasher import PLATFORM_SLUG_TO_RETROACHIEVEMENTS_ID
from handler.metadata.hasheous_handler import HASHEOUS_PLATFORM_LIST
from handler.metadata.launchbox_handler.platforms import LAUNCHBOX_PLATFORM_LIST
from handler.metadata.moby_handler import MOBYGAMES_PLATFORM_LIST
from handler.metadata.ra_handler import RA_PLATFORM_LIST
from handler.metadata.ss_handler import SCREENSAVER_PLATFORM_LIST
from handler.metadata.tgdb_handler import TGDB_PLATFORM_LIST
from utils.platform_slugs import DUPLICATE_PLATFORM_SLUGS
from utils.platform_slugs import UniversalPlatformSlug as UPS
from utils.platform_slugs import fill_duplicate_slugs
def test_fills_either_slug_from_the_other():
platforms = {UPS.VC_4000: 1, UPS.PIPPIN: 2}
fill_duplicate_slugs(platforms)
assert platforms[UPS.INTERTON_VC_4000] == 1
assert platforms[UPS.APPLE_PIPPIN] == 2
assert UPS.VIS not in platforms
assert UPS.TANDY_VIS not in platforms
def test_keeps_both_entries_when_both_are_listed():
platforms = {UPS.VC_4000: 1, UPS.INTERTON_VC_4000: 2}
fill_duplicate_slugs(platforms)
assert platforms == {UPS.VC_4000: 1, UPS.INTERTON_VC_4000: 2}
@pytest.mark.parametrize(
"platforms",
[
IGDB_PLATFORM_LIST,
SCREENSAVER_PLATFORM_LIST,
LAUNCHBOX_PLATFORM_LIST,
RA_PLATFORM_LIST,
PLATFORM_SLUG_TO_RETROACHIEVEMENTS_ID,
TGDB_PLATFORM_LIST,
MOBYGAMES_PLATFORM_LIST,
HASHEOUS_PLATFORM_LIST,
],
ids=["igdb", "ss", "launchbox", "ra", "rahasher", "tgdb", "moby", "hasheous"],
)
def test_provider_lists_cover_both_slugs_or_neither(platforms: dict[UPS, object]):
for slug, duplicate in DUPLICATE_PLATFORM_SLUGS:
assert (slug in platforms) == (duplicate in platforms)