Resume a figure after a library rescan
play_figure resumed only when the player's playlist *was* the figure's playlist object. rescan_library rebuilds every Playlist, so after the refresh button - or the podcast poller landing a new episode, every few hours on its own - putting a figure back started it over. Playlist is a frozen dataclass: compare by value. The album picker's "keep what is already playing" check had the same identity comparison and restarted the album after a rescan; it compares by value too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -126,6 +126,22 @@ async def test_putting_the_same_figure_back_resumes_where_it_left_off(
|
||||
mouse.check("track", "1")
|
||||
|
||||
|
||||
async def test_resuming_survives_a_library_rescan(
|
||||
mouse: SimulatorDriver, sim: Simulation
|
||||
) -> None:
|
||||
"""A rescan rebuilds every Playlist object; resuming must not depend on identity."""
|
||||
await mouse.place("fuchs")
|
||||
await mouse.wait(TRACK_SECONDS + 1)
|
||||
mouse.check("track", "1")
|
||||
|
||||
await mouse.remove()
|
||||
await sim.app.rescan_library()
|
||||
await mouse.place("fuchs")
|
||||
|
||||
mouse.check("playing", "true")
|
||||
mouse.check("track", "1")
|
||||
|
||||
|
||||
async def test_a_different_figure_starts_from_the_top(mouse: SimulatorDriver) -> None:
|
||||
await mouse.place("fuchs")
|
||||
await mouse.wait(TRACK_SECONDS + 1)
|
||||
|
||||
@@ -199,15 +199,15 @@ async def test_play_can_start_at_a_track(client: Client, sim: Simulation) -> Non
|
||||
assert (await client.get("/api/state")).json()["track_index"] == 2
|
||||
|
||||
|
||||
async def test_playing_a_figure_album_reuses_the_figure_playlist(
|
||||
async def test_playing_a_figure_album_plays_the_figure_playlist(
|
||||
client: Client, sim: Simulation
|
||||
) -> None:
|
||||
"""Identity matters: ``play_figure`` resumes on an ``is`` check."""
|
||||
"""Equal to the figure's own playlist, so placing the figure afterwards resumes it."""
|
||||
album = await album_by_title(client, "Fuchs")
|
||||
await client.post("/api/play", json={"album_id": album["id"]})
|
||||
await sim.bus.drain()
|
||||
|
||||
assert sim.player.playlist is sim.app.playlists["fuchs"][0]
|
||||
assert sim.player.playlist == sim.app.playlists["fuchs"][0]
|
||||
|
||||
|
||||
async def test_playing_an_unknown_album_is_a_404(client: Client) -> None:
|
||||
|
||||
Reference in New Issue
Block a user