diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-13 13:06:46 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-13 13:06:46 +0100 |
| commit | ab2ebfd768bcc11f9c9124c15d9da700b9352587 (patch) | |
| tree | 82f1bdd0a1b3d80db375a193edaa2fa7e3615855 /tests | |
| parent | 16fe39a322087ba829ce482284e3fdad86df66a0 (diff) | |
| download | deck-it-ab2ebfd768bcc11f9c9124c15d9da700b9352587.tar.gz deck-it-ab2ebfd768bcc11f9c9124c15d9da700b9352587.zip | |
fix(music): accept a fractional track length
Haruna reports mpris:length as a float (65816666.666666664), so int()
raised and the whole state failed: the widget said nothing was playing
while a video played. Parse length and position as floats.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_music.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_music.py b/tests/test_music.py index aadfcc5..fe603cb 100644 --- a/tests/test_music.py +++ b/tests/test_music.py @@ -38,6 +38,17 @@ class Music(unittest.TestCase): self.assertEqual(st["status"], "Playing") self.assertEqual(st["volume"]["level"], 42) + def test_float_length(self): + # Haruna reports mpris:length as a float. + sep = "\x1f" + fake = lambda cmd, timeout=2: { + "metadata": sep.join(["Playing", "clip.mp4", "", "", "65816666.666666664", + "14583353", "", "haruna"]), + "get-volume": "Volume: 0.42", + }[cmd[1]] + st = music.make({"run": fake}).state() + self.assertAlmostEqual(st["length"], 65.82, places=2) + def test_action_commands(self): self.assertEqual(music.BASE_ACTIONS["next"], ["playerctl", "next"]) |
