mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Swap the hand-rolled platform picker in MissingFirmwareSection for the shared PlatformSelect, and fold the triplicated firmware builder in the tests into an add_firmware factory fixture. Keep Platform out of list_firmware: the relationship is lazy="joined", so every row also ran Platform's rom_count and fs_size_bytes aggregate subqueries over roms, for data no caller reads. In useTaskCompletion, the resolver already identifies the live wait, so drop the parallel generation counter and the unused cancel export. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
"""Tests for the firmware list filters."""
|
|
|
|
from handler.database import db_firmware_handler
|
|
|
|
|
|
class TestListFirmwareMissingFilter:
|
|
def test_lists_everything_without_the_filter(self, platform, add_firmware):
|
|
add_firmware(platform, "present.bin")
|
|
add_firmware(platform, "gone.bin", missing=True)
|
|
|
|
names = [f.file_name for f in db_firmware_handler.list_firmware()]
|
|
assert names == ["gone.bin", "present.bin"]
|
|
|
|
def test_missing_true_returns_only_flagged_firmware(self, platform, add_firmware):
|
|
add_firmware(platform, "present.bin")
|
|
add_firmware(platform, "gone.bin", missing=True)
|
|
|
|
firmware = db_firmware_handler.list_firmware(missing=True)
|
|
assert [f.file_name for f in firmware] == ["gone.bin"]
|
|
|
|
def test_missing_false_excludes_flagged_firmware(self, platform, add_firmware):
|
|
add_firmware(platform, "present.bin")
|
|
add_firmware(platform, "gone.bin", missing=True)
|
|
|
|
firmware = db_firmware_handler.list_firmware(missing=False)
|
|
assert [f.file_name for f in firmware] == ["present.bin"]
|
|
|
|
def test_combines_with_the_platform_filter(
|
|
self, platform, other_platform, add_firmware
|
|
):
|
|
add_firmware(platform, "gone.bin", missing=True)
|
|
add_firmware(other_platform, "other-gone.bin", missing=True)
|
|
|
|
firmware = db_firmware_handler.list_firmware(
|
|
platform_id=platform.id, missing=True
|
|
)
|
|
assert [f.file_name for f in firmware] == ["gone.bin"]
|
|
|
|
def test_combines_with_the_hidden_platform_filter(
|
|
self, platform, other_platform, add_firmware
|
|
):
|
|
add_firmware(platform, "gone.bin", missing=True)
|
|
add_firmware(other_platform, "other-gone.bin", missing=True)
|
|
|
|
firmware = db_firmware_handler.list_firmware(
|
|
missing=True, hidden_platform_ids=[other_platform.id]
|
|
)
|
|
assert [f.file_name for f in firmware] == ["gone.bin"]
|