app: Fix bug when a tag that has no playlist is encountered
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m23s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m23s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
This commit is contained in:
@@ -69,7 +69,7 @@ class PlayerApp:
|
||||
|
||||
def _set_playlist(self, tag: bytes):
|
||||
self.playlist = self.playlist_db.getPlaylistForTag(tag)
|
||||
self._play(self.playlist.getCurrentPath())
|
||||
self._play(self.playlist.getCurrentPath() if self.playlist is not None else None)
|
||||
|
||||
def _play_next(self):
|
||||
if self.playlist is None:
|
||||
|
||||
@@ -137,3 +137,21 @@ def test_playlist_seq(micropythonify, faketimermanager, monkeypatch):
|
||||
fake_mp3.track = None
|
||||
dut.onPlaybackDone()
|
||||
assert fake_mp3.track is None
|
||||
|
||||
|
||||
def test_playlist_unknown_tag(micropythonify, faketimermanager, monkeypatch):
|
||||
class FakeNoPlaylistDb:
|
||||
def getPlaylistForTag(self, tag):
|
||||
return None
|
||||
|
||||
fake_db = FakeNoPlaylistDb()
|
||||
fake_mp3 = FakeMp3Player()
|
||||
deps = app.Dependencies(mp3player=lambda _: fake_mp3,
|
||||
nfcreader=lambda _: FakeNfcReader(),
|
||||
buttons=lambda _: FakeButtons(),
|
||||
playlistdb=lambda _: fake_db)
|
||||
dut = app.PlayerApp(deps)
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr(builtins, 'open', fake_open)
|
||||
dut.onTagChange([23, 42, 1, 2, 3])
|
||||
assert fake_mp3.track is None
|
||||
|
||||
Reference in New Issue
Block a user