mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Teaches the streaming endpoints the webstation activate/exit contract alongside the existing per-emulator broker mods, lets one container serve a pool of platforms, and claims the first free container from that pool. Sessions now sync save states, save archives and whole memory cards back into the RomM library on release, keep every capture as browsable history, and record the disc a state was taken on so a resume remounts it. Container adoptions track a card the container already held so it is never wiped without asking.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
from handler.database import db_rom_handler, db_state_handler
|
|
from models.assets import Save, Screenshot, State
|
|
from models.rom import Rom
|
|
|
|
|
|
def test_save(save: Save):
|
|
assert "test_platform_slug/saves/test_emulator/test_save.sav" in save.full_path
|
|
assert save.download_path.startswith(f"/api/saves/{save.id}/content")
|
|
|
|
|
|
def test_state(state: State):
|
|
assert "test_platform_slug/states/test_emulator/test_state.state" in state.full_path
|
|
assert state.download_path.startswith(f"/api/states/{state.id}/content")
|
|
|
|
|
|
def test_screenshot(screenshot: Screenshot):
|
|
assert "test_platform_slug/screenshots/test_screenshot.png" in screenshot.full_path
|
|
assert screenshot.download_path.startswith(
|
|
f"/api/screenshots/{screenshot.id}/content"
|
|
)
|
|
|
|
|
|
def test_a_state_defaults_to_no_disc(state: State):
|
|
"""A single-disc game records nothing, so the column stays empty."""
|
|
assert state.disc_file_id is None
|
|
|
|
|
|
def test_losing_the_disc_file_does_not_take_the_state_with_it(
|
|
state: State, multi_file_rom: Rom
|
|
):
|
|
"""A rescan that drops a file row must cost the state its disc hint, not the
|
|
save itself, so the column is SET NULL rather than CASCADE."""
|
|
disc = multi_file_rom.files[1]
|
|
db_state_handler.update_state(state.id, {"disc_file_id": disc.id})
|
|
|
|
db_rom_handler.delete_rom_file(disc.id)
|
|
|
|
survivor = db_state_handler.get_state(user_id=state.user_id, id=state.id)
|
|
assert survivor is not None
|
|
assert survivor.disc_file_id is None
|