[frontend] Accept tl_track in track_playback_started
All checks were successful
Deploy to mopidy1 / deploy (push) Successful in 26s
All checks were successful
Deploy to mopidy1 / deploy (push) Successful in 26s
Mopidy's CoreListener calls track_playback_started(tl_track=...), but the method took a positional `track`, so every playback start raised TypeError and the smart queue never refilled on track changes. Add a regression test.
This commit is contained in:
@ -14,6 +14,8 @@ from mopidy_smartplaylists.generators import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from mopidy.models import TlTrack
|
||||||
|
|
||||||
from mopidy_smartplaylists.compat import Config, CoreProxy, Uri
|
from mopidy_smartplaylists.compat import Config, CoreProxy, Uri
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -63,7 +65,8 @@ class SmartPlaylistsFrontend(pykka.ThreadingActor, CoreListener):
|
|||||||
logger.info("Smart playlists loaded, running refresh...")
|
logger.info("Smart playlists loaded, running refresh...")
|
||||||
refresh_smart_playlists(self.core, section)
|
refresh_smart_playlists(self.core, section)
|
||||||
|
|
||||||
def track_playback_started(self, track) -> None:
|
def track_playback_started(self, tl_track: TlTrack | None = None) -> None:
|
||||||
|
logger.debug("Track playback started: %s", tl_track)
|
||||||
self._refill_queue()
|
self._refill_queue()
|
||||||
|
|
||||||
def tracklist_changed(self) -> None:
|
def tracklist_changed(self) -> None:
|
||||||
|
|||||||
@ -74,3 +74,16 @@ class TestSmartPlaylistsFrontend:
|
|||||||
frontend.playlists_loaded()
|
frontend.playlists_loaded()
|
||||||
|
|
||||||
core.library.search.assert_not_called()
|
core.library.search.assert_not_called()
|
||||||
|
|
||||||
|
def test_track_playback_started_accepts_tl_track(self):
|
||||||
|
config = mock.Mock()
|
||||||
|
config.get.return_value = {
|
||||||
|
"playlist_prefix": "[Smart]",
|
||||||
|
"smart_queue_enabled": "false",
|
||||||
|
}
|
||||||
|
core = mock.Mock()
|
||||||
|
|
||||||
|
frontend = SmartPlaylistsFrontend(config, core)
|
||||||
|
frontend.track_playback_started(tl_track=mock.Mock())
|
||||||
|
|
||||||
|
core.tracklist.add.assert_not_called()
|
||||||
|
|||||||
Reference in New Issue
Block a user