Add spotify queue
Deploy HEOS panel / deploy (push) Successful in 30s

This commit is contained in:
franzz committed 2026-10-20 15:44:56 +02:00
1 parent 6c76121863
commit 6bee9bd9a3
13 files changed
+230 -5

No files matched your search

+8 -1
View File
@@ -1,5 +1,5 @@
"""Stand-in Spotify Web API: just enough of /api/token, .../player/devices,
.../player, .../player/pause and .../player/seek to test spotify.py against, the same way
.../player, .../player/queue, .../player/pause and .../player/seek to test spotify.py against, the same way
fakes.py stands in for real HEOS hardware."""
import json
@@ -27,6 +27,7 @@ class FakeSpotify(threading.Thread):
self.reject_refresh = False # simulate a revoked refresh token
self.scope = "user-read-playback-state user-modify-playback-state"
self.player = None # GET /v1/me/player's body; None is no session (204)
self.queue = [] # GET /v1/me/player/queue's "queue"
self.forbid = None # a plain-text 403 body every API call answers with
fake = self
@@ -130,6 +131,12 @@ class FakeSpotify(threading.Thread):
else:
self._send(200, fake.player)
return
if self.path == "/v1/me/player/queue":
if not self._authorized():
self._send(401, {"error": {"message": "The access token expired"}})
return
self._send(200, {"currently_playing": None, "queue": fake.queue})
return
self._send(404, {"error": {"message": "not found"}})
self.server = HTTPServer(("127.0.0.1", 0), Handler)
+4
View File
@@ -64,6 +64,10 @@ class SpotifyTest(unittest.TestCase):
self.client.seek(90000)
self.assertEqual(self.fake.seeks, [90000])
def test_queue_lists_what_comes_next_in_order(self):
self.fake.queue = [{"name": "Old King"}, {"name": "Natural Beauty"}]
self.assertEqual([i["name"] for i in self.client.queue()], ["Old King", "Natural Beauty"])
def test_playback_reports_the_device_and_whether_it_plays(self):
self.fake.player = {"device": {"id": "dev-1", "name": "Lego Room"}, "is_playing": True}
player = self.client.playback()