Files
romm/backend/tests/utils/test_arcade_platforms.py
Spinnich 60703be09c chore(platforms): split arcade aliases into per-emulator-family slugs (#5273)
* feat(platforms): split arcade aliases into per-emulator-family slugs

Give MAME, AdvanceMAME, FBNeo, FBA, Daphne, Singe and the arcade boards
that need their own emulator (NAOMI/NAOMI 2/NAOMI GD-ROM, Model 2/3,
Hikaru, Triforce, Lindbergh, Namco System 246/3xx, Gaelco, ...) their own
slugs with verified provider IDs. Providers without a dedicated entry fall
back to their Arcade platform via arcade_fallbacks(). MAME-only boards
(CPS1-3, System 16/32, Model 1, Namco 22) stay aliases of arcade.

Refs #5272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): code-review pass on arcade slugs

- Retry IGDB on unmatched scans for every platform IGDB resolves, not
  just slugs in IGDB_PLATFORM_LIST.
- Resolve config binding/version values through the alias table, so a
  binding to a retired slug (cps2, model1, ...) still lands on a platform.
- Alias the Batocera `typex` folder to type-x.
- Build provider id->slug reverse maps before merging Arcade fallbacks.
- Share one MAME title lookup between base_handler and libretro.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(platforms): simplify pass on arcade slugs

- Alias the three RomM-keyed IGDB versions inside IGDB_PLATFORM_VERSIONS,
  dropping IGDB_VERSION_SLUGS and _version_slug.
- Derive EmulatorJS arcade entries from ARCADE_SET_PLATFORMS.
- Remove the unused provider id->slug reverse maps, so the Arcade
  fallback merge no longer has an ordering constraint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(platforms): humanizer pass on arcade slug comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): settle arcade slug review decisions

- Migration 0154 moves platforms still on a retired MAME-only board slug
  (cps1-3, model1, system16, system32, system-32) to arcade, so no row
  carries a slug the enum no longer has.
- MAME shortname expansion keys off the RomM slug via
  MAME_SHORTNAME_PLATFORMS instead of per-provider arcade ids, so Daphne,
  Singe, Type X and Lindbergh sets are no longer read as MAME sets. Neo Geo
  now expands at ScreenScraper too, as it already did at IGDB and Moby.
- fba offers fbneo before the FinalBurn Alpha CPS cores.
- AdvanceMAME leaves the WebRcade feed; EmulatorJS and WebRcade share
  PLAYABLE_ARCADE_SET_PLATFORMS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): code-review pass (xhigh) on arcade slugs

Verify arcade-board BIOS files against the known list's arcade entries,
and make migration 0154 match retired slugs case-insensitively.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(platforms): simplify pass on arcade slugs

Apply IGDB family overrides once in get_platform instead of on each
return path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(platforms): use a slug with no shipped icon

singe now ships an icon, so the no-icon prefetch test needs a slug that never will.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(platforms): add a teknoparrot arcade slug

TeknoParrot runs PC-based arcade boards outside the MAME/FinalBurn family,
so its folder gets its own platform (RetroBat and ES-DE both use
`teknoparrot`). Providers fall back to their Arcade entry, MAME shortname
expansion skips it, and it gets a placeholder icon copied from `arcade`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(platforms): give each arcade-family icon its own marquee title

Redraws the ARCADE marquee on the copied cabinet icons with each
platform's name, in the Bungee typeface with the original inline and
extrusion styling. Sega boards use Sega blue, Namco systems Namco red,
and Type X Taito blue; the rest keep the original amber.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): code-review pass (xhigh) on arcade slugs

Neo Geo BIOS lives under arcade in the known BIOS list, so map
neogeoaes and neogeomvs there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(platforms): simplify pass on arcade slug tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
2026-10-28 19:53:06 -04:00

75 lines
2.6 KiB
Python

import pytest
from endpoints.responses.feeds import (
WEBRCADE_SLUG_TO_TYPE_MAP,
WEBRCADE_SUPPORTED_PLATFORM_SLUGS,
)
from handler.database.roms_handler import EJS_SUPPORTED_PLATFORMS
from handler.metadata import (
meta_hasheous_handler,
meta_hltb_handler,
meta_launchbox_handler,
meta_moby_handler,
meta_ra_handler,
meta_ss_handler,
meta_tgdb_handler,
)
from handler.metadata.platform_names import resolve_platform_name
from utils.arcade_platforms import (
ARCADE_PLATFORMS,
ARCADE_SET_PLATFORMS,
arcade_fallbacks,
)
from utils.platform_slugs import UniversalPlatformSlug as UPS
BOARD_PLATFORMS = sorted(ARCADE_PLATFORMS - ARCADE_SET_PLATFORMS)
PLAYABLE_SETS = {UPS.ARCADE, UPS.MAME, UPS.FBNEO, UPS.FBA}
def test_fallbacks_keep_a_providers_own_entry():
platforms = {UPS.ARCADE: "arcade", UPS.NAOMI: "naomi"}
assert arcade_fallbacks(platforms, [UPS.NAOMI, UPS.MAME]) == {UPS.MAME: "arcade"}
@pytest.mark.parametrize("slug", sorted(ARCADE_PLATFORMS))
def test_every_arcade_platform_is_looked_up_at_every_provider(slug: UPS):
assert meta_ss_handler.get_platform(slug)["ss_id"]
assert meta_launchbox_handler.get_platform(slug)["launchbox_id"]
assert meta_moby_handler.get_platform(slug)["moby_id"]
assert meta_tgdb_handler.get_platform(slug)["tgdb_id"]
assert meta_hasheous_handler.get_platform(slug)["hasheous_id"]
assert meta_hltb_handler.get_platform(slug)["hltb_slug"]
@pytest.mark.parametrize("slug", sorted(ARCADE_PLATFORMS - {UPS.ARCADE}))
def test_an_arcade_platform_is_not_named_arcade(slug: UPS):
assert resolve_platform_name(slug) != "Arcade"
@pytest.mark.parametrize("slug", sorted(ARCADE_SET_PLATFORMS))
def test_a_set_platform_gets_retroachievements_arcade(slug: UPS):
assert meta_ra_handler.get_platform(slug)["ra_id"] == 27
assert meta_hasheous_handler.get_platform(slug)["ra_id"] == 27
@pytest.mark.parametrize("slug", BOARD_PLATFORMS)
def test_a_board_gets_no_retroachievements_console(slug: UPS):
assert meta_ra_handler.get_platform(slug)["ra_id"] is None
assert meta_hasheous_handler.get_platform(slug)["ra_id"] is None
def test_only_sets_an_emulatorjs_core_runs_are_playable():
assert PLAYABLE_SETS <= set(EJS_SUPPORTED_PLATFORMS)
assert not (ARCADE_PLATFORMS - PLAYABLE_SETS) & set(EJS_SUPPORTED_PLATFORMS)
@pytest.mark.parametrize("slug", sorted(PLAYABLE_SETS))
def test_set_platforms_feed_webrcade_as_arcade(slug: UPS):
assert slug in WEBRCADE_SUPPORTED_PLATFORM_SLUGS
assert WEBRCADE_SLUG_TO_TYPE_MAP[slug] == "arcade"
def test_advancemame_is_left_out_of_webrcade():
assert UPS.MAME_ADVMAME not in WEBRCADE_SUPPORTED_PLATFORM_SLUGS