1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
import unittest
from unittest import mock
import pykka
from mopidy import core
from mopidy.internal import deprecation
from mopidy.models import Track
from tests import dummy_backend
@mock.patch.object(core.CoreListener, "send")
class BackendEventsTest(unittest.TestCase):
def setUp(self): # noqa: N802
config = {"core": {"max_tracklist_length": 10000}}
self.backend = dummy_backend.create_proxy()
self.backend.library.dummy_library = [
Track(uri="dummy:a"),
Track(uri="dummy:b"),
]
with deprecation.ignore():
self.core = core.Core.start(config, backends=[self.backend]).proxy()
def tearDown(self): # noqa: N802
pykka.ActorRegistry.stop_all()
def test_forwards_backend_playlists_loaded_event_to_frontends(self, send):
self.core.playlists_loaded().get()
assert send.call_args[0][0] == "playlists_loaded"
def test_forwards_mixer_volume_changed_event_to_frontends(self, send):
self.core.volume_changed(volume=60).get()
assert send.call_args[0][0] == "volume_changed"
assert send.call_args[1]["volume"] == 60
def test_forwards_mixer_mute_changed_event_to_frontends(self, send):
self.core.mute_changed(mute=True).get()
assert send.call_args[0][0] == "mute_changed"
assert send.call_args[1]["mute"] is True
def test_tracklist_add_sends_tracklist_changed_event(self, send):
self.core.tracklist.add(uris=["dummy:a"]).get()
assert send.call_args[0][0] == "tracklist_changed"
def test_tracklist_clear_sends_tracklist_changed_event(self, send):
self.core.tracklist.add(uris=["dummy:a"]).get()
self.core.tracklist.clear().get()
assert send.call_args[0][0] == "tracklist_changed"
def test_tracklist_move_sends_tracklist_changed_event(self, send):
self.core.tracklist.add(uris=["dummy:a", "dummy:b"]).get()
self.core.tracklist.move(0, 1, 1).get()
assert send.call_args[0][0] == "tracklist_changed"
def test_tracklist_remove_sends_tracklist_changed_event(self, send):
self.core.tracklist.add(uris=["dummy:a"]).get()
self.core.tracklist.remove({"uri": ["dummy:a"]}).get()
assert send.call_args[0][0] == "tracklist_changed"
def test_tracklist_shuffle_sends_tracklist_changed_event(self, send):
self.core.tracklist.add(uris=["dummy:a", "dummy:b"]).get()
self.core.tracklist.shuffle().get()
assert send.call_args[0][0] == "tracklist_changed"
def test_playlists_refresh_sends_playlists_loaded_event(self, send):
self.core.playlists.refresh().get()
assert send.call_args[0][0] == "playlists_loaded"
def test_playlists_refresh_uri_sends_playlists_loaded_event(self, send):
self.core.playlists.refresh(uri_scheme="dummy").get()
assert send.call_args[0][0] == "playlists_loaded"
def test_playlists_create_sends_playlist_changed_event(self, send):
self.core.playlists.create("foo").get()
assert send.call_args[0][0] == "playlist_changed"
def test_playlists_delete_sends_playlist_deleted_event(self, send):
playlist = self.core.playlists.create("foo").get()
self.core.playlists.delete(playlist.uri).get()
assert send.call_args[0][0] == "playlist_deleted"
def test_playlists_save_sends_playlist_changed_event(self, send):
playlist = self.core.playlists.create("foo").get()
playlist = playlist.replace(name="bar")
self.core.playlists.save(playlist).get()
assert send.call_args[0][0] == "playlist_changed"
|