Remove dead code
- wire.with_figure: the device uses dataclasses.replace directly. - DeviceConnected/DeviceDisconnected: emitted, never subscribed to, and a duplicate of ConnectionChanged(target="firmware"). - ScreenService.toggle(): never called. - GET /api/lirc (LircConfigOut, api.lircConfig): no front-end reads it. - POST /api/volume's delta_percent (api.nudgeVolume): no front-end sends it. - LibraryCache.shrink_stored_covers: a one-off migration that re-read every cover header on every scan. _INDEX_VERSION 7 rebuilds any cache that could still need it. - Firmware: the MFRC522 library and its unused globals (lib/nfc/rc522.c is the driver in use), and mfrc_version.h, a reader test sketch nothing included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -916,46 +916,3 @@ class TestCoverDownscaling:
|
||||
assert thumb.format == "JPEG"
|
||||
assert "progressive" not in thumb.info
|
||||
assert abs(thumb.width / thumb.height - 2400 / 1800) < 0.02
|
||||
|
||||
def test_thumbnails_are_backfilled_for_covers_stored_without_one(
|
||||
self, tmp_path: Path
|
||||
) -> None:
|
||||
from PIL import Image
|
||||
|
||||
from musicmouse.library.cache import THUMB_COVER_PX, LibraryCache
|
||||
|
||||
cache = LibraryCache(tmp_path)
|
||||
cache.prepare()
|
||||
cache.cover_path("old").write_bytes(self._jpeg((384, 384)))
|
||||
assert not cache.thumb_path("old").exists()
|
||||
|
||||
assert cache.shrink_stored_covers() == 0 # nothing oversized...
|
||||
with Image.open(cache.thumb_path("old")) as thumb: # ...but the thumb appeared
|
||||
assert max(thumb.size) == THUMB_COVER_PX
|
||||
# Steady state: the thumbnail is not regenerated, and is not mistaken for a cover.
|
||||
before = cache.thumb_path("old").stat().st_mtime_ns
|
||||
assert cache.shrink_stored_covers() == 0
|
||||
assert cache.thumb_path("old").stat().st_mtime_ns == before
|
||||
assert not cache.thumb_path("old.thumb").exists()
|
||||
|
||||
def test_covers_written_by_an_older_version_are_migrated(self, tmp_path: Path) -> None:
|
||||
"""The scanner reuses an unchanged album without re-reading its tags, so a
|
||||
cover stored before the limit existed would otherwise never be rewritten."""
|
||||
from PIL import Image
|
||||
|
||||
from musicmouse.library.cache import MAX_COVER_PX, LibraryCache
|
||||
|
||||
cache = LibraryCache(tmp_path)
|
||||
cache.prepare()
|
||||
stale = cache.cover_path("old")
|
||||
stale.write_bytes(self._jpeg((3000, 3000)))
|
||||
fresh = cache.cover_path("new")
|
||||
fresh.write_bytes(self._jpeg((320, 320)))
|
||||
fresh_before = fresh.read_bytes()
|
||||
|
||||
assert cache.shrink_stored_covers() == 1
|
||||
with Image.open(stale) as image:
|
||||
assert max(image.size) == MAX_COVER_PX
|
||||
assert fresh.read_bytes() == fresh_before
|
||||
# Second pass has nothing left to do - the cheap steady state.
|
||||
assert cache.shrink_stored_covers() == 0
|
||||
|
||||
@@ -65,13 +65,6 @@ async def album_id(sim: Simulation, title: str) -> str:
|
||||
return next(a.id for a in sim.app.library.albums if a.title == title)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------ lirc
|
||||
|
||||
|
||||
async def test_lirc_is_a_404_when_unconfigured(client: httpx2.AsyncClient) -> None:
|
||||
assert (await client.get("/api/lirc")).status_code == 404
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- reading
|
||||
|
||||
|
||||
|
||||
@@ -288,24 +288,6 @@ async def test_volume_scales_across_the_allowed_range(client: Client, sim: Simul
|
||||
assert (await client.get("/api/state")).json()["volume"] == 50
|
||||
|
||||
|
||||
async def test_volume_steps_are_relative_to_the_percentage(client: Client, sim: Simulation) -> None:
|
||||
await client.post("/api/volume", json={"percent": 50})
|
||||
await sim.bus.drain()
|
||||
await client.post("/api/volume", json={"delta_percent": 10})
|
||||
await sim.bus.drain()
|
||||
|
||||
assert (await client.get("/api/state")).json()["volume"] == 60
|
||||
assert sim.player.volume == 36
|
||||
|
||||
|
||||
async def test_volume_steps_clamp_at_the_ends(client: Client, sim: Simulation) -> None:
|
||||
await client.post("/api/volume", json={"percent": 95})
|
||||
await sim.bus.drain()
|
||||
await client.post("/api/volume", json={"delta_percent": 20})
|
||||
await sim.bus.drain()
|
||||
assert (await client.get("/api/state")).json()["volume"] == 100
|
||||
|
||||
|
||||
async def test_remote_steps_move_by_the_volume_increment(client: Client, sim: Simulation) -> None:
|
||||
"""The +/- buttons take the IR remote's step, in device units, not a percentage."""
|
||||
await client.post("/api/volume", json={"percent": 50})
|
||||
|
||||
Reference in New Issue
Block a user