Typing lessons like duolingo & musicmouse cleanup
This commit is contained in:
@@ -419,14 +419,18 @@ async def test_transport_buttons_emit_intents(
|
||||
|
||||
|
||||
async def test_the_player_sensor_reports_the_current_track(
|
||||
bus: EventBus, mqtt_config: MqttConfig, player: FakePlayer, publisher: RecordingPublisher
|
||||
bus: EventBus,
|
||||
mqtt_config: MqttConfig,
|
||||
mouse: MusicMouseDevice,
|
||||
player: FakePlayer,
|
||||
publisher: RecordingPublisher,
|
||||
) -> None:
|
||||
from pathlib import Path
|
||||
|
||||
from musicmouse.media import Playlist, Track
|
||||
from musicmouse.services.mqtt.player import PlayerSensor
|
||||
|
||||
entity = PlayerSensor(bus, mqtt_config, player)
|
||||
entity = PlayerSensor(bus, mqtt_config, mouse, player)
|
||||
entity.attach(publisher)
|
||||
player.set_playlist(Playlist(name="fuchs", tracks=(Track(Path("/m/01 - Song.mp3")),)))
|
||||
player.play_from_start()
|
||||
@@ -439,6 +443,29 @@ async def test_the_player_sensor_reports_the_current_track(
|
||||
assert attributes["volume"] == 40
|
||||
|
||||
|
||||
async def test_the_player_sensor_reports_the_mouse_s_active_figure(
|
||||
bus: EventBus,
|
||||
mqtt_config: MqttConfig,
|
||||
transport: FakeTransport,
|
||||
mouse: MusicMouseDevice,
|
||||
player: FakePlayer,
|
||||
publisher: RecordingPublisher,
|
||||
) -> None:
|
||||
"""The sensor reads ``mouse.active_figure`` rather than keeping its own copy of it,
|
||||
so it agrees with the mouse even if it missed the event that changed it."""
|
||||
from musicmouse.services.mqtt.player import PlayerSensor
|
||||
|
||||
entity = PlayerSensor(bus, mqtt_config, mouse, player)
|
||||
entity.attach(publisher)
|
||||
|
||||
transport.inject(RfidTokenRead(tag_id=bytes.fromhex("04a1b2c3d4"), source="device"))
|
||||
await bus.drain()
|
||||
|
||||
attributes = publisher.last_json(f"{entity.base_topic}/attributes")
|
||||
assert attributes["figure"] == "fuchs"
|
||||
assert mouse.active_figure == "fuchs"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------- triggers
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user