Files
romm/backend/tests/adapters/services/conftest.py
Georges-Antoine Assi 50b03f8cc7 refactor(steam): drop redundant work found in review
Remove the roms_facets backfill from 0115: the steam columns are created by
that same revision, so it was a full-table UPDATE writing NULL over NULL at
container start. Migration 0114, which adds provider columns the same way,
has no backfill either.

Collapse the nine hand-written raw_*_metadata blocks in updateRom into a loop
over raw_metadata, so a new provider no longer needs a copy-pasted block.

Reuse the shared disable_metadata_rate_limiters fixture for the Steam adapter
tests instead of a second local one, move STEAM_PLATFORMS up to the constant
block it belongs to, and trim a test docstring that restated the rationale
already sitting next to resolve_steam_rom.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 17:05:18 -04:00

43 lines
1.3 KiB
Python

from contextvars import ContextVar
from unittest.mock import AsyncMock
import aiohttp
import pytest
import pytest_asyncio
from adapters.services.screenscraper import SS_DEFAULT_MAX_THREADS
from utils.rate_limiter import ConcurrencyLimiter
@pytest.fixture(autouse=True)
def disable_metadata_rate_limiters(monkeypatch):
"""Neutralize the pre-emptive rate limiters during tests."""
for module in (
"adapters.services.igdb",
"adapters.services.mobygames",
"adapters.services.retroachievements",
"adapters.services.steam",
):
mod = __import__(module, fromlist=["_rate_limiter"])
monkeypatch.setattr(mod._rate_limiter, "acquire", AsyncMock())
# Swap in a fresh instance of the concurrency limiter for each test
monkeypatch.setattr(
"adapters.services.screenscraper._concurrency_limiter",
ConcurrencyLimiter(SS_DEFAULT_MAX_THREADS),
)
@pytest_asyncio.fixture
async def mock_ctx_aiohttp_session():
"""Create a real aiohttp session for integration tests."""
session = aiohttp.ClientSession()
ctx_aiohttp_session: ContextVar[aiohttp.ClientSession] = ContextVar(
"aiohttp_session"
)
ctx_aiohttp_session.set(session)
try:
yield ctx_aiohttp_session
finally:
await session.close()