Beispiel #1
0
    def setup_method(self, method):
        self.audio = dummy_audio.create_proxy(config=self.config, mixer=None)
        self.backend = MyTestBackend.start(
            audio=self.audio, config=self.config
        ).proxy()
        self.core = core.Core(
            audio=self.audio, backends=[self.backend], config=self.config
        )
        self.playback = self.core.playback

        # We don't have a core actor running, so call about to finish directly.
        self.audio.set_about_to_finish_callback(
            self.playback._on_about_to_finish
        )

        with deprecation.ignore():
            self.core.tracklist.add(self.tracks)

        self.events = []
        self.patcher = mock.patch("mopidy.audio.listener.AudioListener.send")
        self.send_mock = self.patcher.start()

        def send(event, **kwargs):
            self.events.append((event, kwargs))

        self.send_mock.side_effect = send
Beispiel #2
0
    def setUp(self):  # noqa: N802
        self.config['m3u']['playlists_dir'] = tempfile.mkdtemp()
        self.playlists_dir = self.config['m3u']['playlists_dir']

        audio = dummy_audio.create_proxy()
        backend = M3UBackend.start(config=self.config, audio=audio).proxy()
        self.core = core.Core(backends=[backend])
Beispiel #3
0
    def setUp(self):  # noqa: N802
        if self.enable_mixer:
            self.mixer = dummy_mixer.create_proxy()
        else:
            self.mixer = None
        self.audio = dummy_audio.create_proxy()
        self.backend = dummy_backend.create_proxy(audio=self.audio)

        self.core = core.Core.start(
            self.get_config(),
            audio=self.audio,
            mixer=self.mixer,
            backends=[self.backend],
        ).proxy()

        self.uri_map = uri_mapper.MpdUriMapper(self.core)
        self.connection = MockConnection()
        self.session = session.MpdSession(
            self.connection,
            config=self.get_config(),
            core=self.core,
            uri_map=self.uri_map,
        )
        self.dispatcher = self.session.dispatcher
        self.context = self.dispatcher.context
Beispiel #4
0
    def setUp(self):  # noqa: N802
        self.config['m3u']['playlists_dir'] = tempfile.mkdtemp()
        self.playlists_dir = self.config['m3u']['playlists_dir']

        audio = dummy_audio.create_proxy()
        backend = actor.M3UBackend.start(
            config=self.config, audio=audio).proxy()
        self.core = core.Core(backends=[backend])
Beispiel #5
0
    def setUp(self):  # noqa: N802
        self.audio = dummy_audio.create_proxy()
        self.backend = actor.LocalBackend.start(config=self.config, audio=self.audio).proxy()
        self.core = core.Core.start(audio=self.audio, backends=[self.backend], config=self.config).proxy()
        self.controller = self.core.tracklist
        self.playback = self.core.playback

        assert len(self.tracks) == 3, "Need three tracks to run tests."
Beispiel #6
0
    def setUp(self):  # noqa: N802
        self.config["m3u"]["playlists_dir"] = pathlib.Path(tempfile.mkdtemp())
        self.playlists_dir = self.config["m3u"]["playlists_dir"]
        self.base_dir = self.config["m3u"]["base_dir"] or self.playlists_dir

        audio = dummy_audio.create_proxy()
        backend = M3UBackend.start(config=self.config, audio=audio).proxy()
        self.core = core.Core(backends=[backend])
Beispiel #7
0
    def setUp(self):  # noqa: N802
        self.audio = dummy_audio.create_proxy()
        self.backend = actor.LocalBackend.start(config=self.config, audio=self.audio).proxy()
        self.core = core.Core(backends=[self.backend])
        self.playback = self.core.playback
        self.tracklist = self.core.tracklist

        assert len(self.tracks) >= 3, "Need at least three tracks to run tests."
        assert self.tracks[0].length >= 2000, "First song needs to be at least 2000 miliseconds"
Beispiel #8
0
    def setUp(self):  # noqa: N802
        self.audio = dummy_audio.create_proxy()
        self.backend = actor.LocalBackend.start(config=self.config,
                                                audio=self.audio).proxy()
        self.core = core.Core(self.config, mixer=None, backends=[self.backend])
        self.controller = self.core.tracklist
        self.playback = self.core.playback

        assert len(self.tracks) == 3, 'Need three tracks to run tests.'
Beispiel #9
0
 def setUp(self):
     self.audio = dummy_audio.create_proxy()
     self.backend = actor.LocalBackend.start(config=self.config,
                                             audio=self.audio).proxy()
     self.core = core.Core.start(audio=self.audio,
                                 backends=[self.backend],
                                 config=self.config).proxy()
     self.library = self.backend.library
     self.storage = storage.LocalStorageProvider(self.config)
     self.storage.load()
Beispiel #10
0
    def setUp(self):  # noqa: N802
        self.audio = dummy_audio.create_proxy()
        self.backend = actor.LocalBackend.start(config=self.config,
                                                audio=self.audio).proxy()
        self.core = core.Core(self.config, backends=[self.backend])
        self.playback = self.core.playback
        self.tracklist = self.core.tracklist

        assert len(self.tracks) >= 3, \
            'Need at least three tracks to run tests.'
        assert self.tracks[0].length >= 2000, \
            'First song needs to be at least 2000 miliseconds'
Beispiel #11
0
    def setUp(self):  # noqa: N802
        config = {"core": {"max_tracklist_length": 10000}}

        self.audio = dummy_audio.create_proxy()
        self.mixer = dummy_mixer.create_proxy()
        self.backend = dummy_backend.create_proxy(audio=self.audio)

        with deprecation.ignore():
            self.core = core.Core.start(config, audio=self.audio, mixer=self.mixer, backends=[self.backend]).proxy()

        self.dispatcher = dispatcher.MpdDispatcher(core=self.core)
        self.context = self.dispatcher.context
Beispiel #12
0
    def setUp(self):  # noqa: N802
        config = {"core": {"max_tracklist_length": 10000}}

        self.audio = dummy_audio.create_proxy()
        self.mixer = dummy_mixer.create_proxy()
        self.backend = dummy_backend.create_proxy(audio=self.audio)

        self.core = core.Core.start(
            config, audio=self.audio, mixer=self.mixer, backends=[self.backend],
        ).proxy()

        self.dispatcher = dispatcher.MpdDispatcher(core=self.core)
        self.context = self.dispatcher.context
Beispiel #13
0
    def __init__(self):
        config = {"core": {"max_tracklist_length": 10000}}

        self.audio = dummy_audio.create_proxy(DummyAudio)
        self.backend = dummy_backend.create_proxy(DummyPandoraBackend,
                                                  audio=self.audio)
        self.non_pandora_backend = dummy_backend.create_proxy(DummyBackend,
                                                              audio=self.audio)

        self.core = core.Core.start(
            config,
            audio=self.audio,
            backends=[self.backend, self.non_pandora_backend],
        ).proxy()

        def lookup(uris):
            result = {uri: [] for uri in uris}
            for track in self.tracks:
                if track.uri in result:
                    result[track.uri].append(track)
            return result

        self.core.library.lookup = lookup
        self.tl_tracks = self.core.tracklist.add(uris=self.uris).get()

        self.events = queue.Queue()

        def send(cls, event, **kwargs):
            self.events.put((cls, event, kwargs))

        self.patcher = mock.patch("mopidy.listener.send")
        self.send_mock = self.patcher.start()
        self.send_mock.side_effect = send

        # TODO: Remove this patcher once Mopidy 1.2 has been released.
        try:
            self.core_patcher = mock.patch("mopidy.listener.send_async")
            self.core_send_mock = self.core_patcher.start()
            self.core_send_mock.side_effect = send
        except AttributeError:
            # Mopidy > 1.1 no longer has mopidy.listener.send_async
            pass

        self.actor_register = [self.backend, self.core, self.audio]
Beispiel #14
0
    def setUp(self):  # noqa: N802
        config = {
            'core': {
                'max_tracklist_length': 10000,
            }
        }

        self.audio = dummy_audio.create_proxy()
        self.mixer = dummy_mixer.create_proxy()
        self.backend = dummy_backend.create_proxy(audio=self.audio)

        with deprecation.ignore():
            self.core = core.Core.start(config,
                                        audio=self.audio,
                                        mixer=self.mixer,
                                        backends=[self.backend]).proxy()

        self.dispatcher = dispatcher.MpdDispatcher(core=self.core)
        self.context = self.dispatcher.context
Beispiel #15
0
    def setUp(self):  # noqa: N802
        if self.enable_mixer:
            self.mixer = dummy_mixer.create_proxy()
        else:
            self.mixer = None
        self.audio = dummy_audio.create_proxy()
        self.backend = dummy_backend.create_proxy(audio=self.audio)

        with deprecation.ignore():
            self.core = core.Core.start(
                self.get_config(),
                audio=self.audio,
                mixer=self.mixer,
                backends=[self.backend]).proxy()

        self.uri_map = uri_mapper.MpdUriMapper(self.core)
        self.connection = MockConnection()
        self.session = session.MpdSession(
            self.connection, config=self.get_config(), core=self.core,
            uri_map=self.uri_map)
        self.dispatcher = self.session.dispatcher
        self.context = self.dispatcher.context
def frontend(monkeypatch):
    config = {
        "choosmoos": {
            "nfc_demo_app_location": None,
            "next_pin_number": 3,
            "previous_pin_number": 4,
            "volume_up_pin_number": 1,
            "volume_down_pin_number": 2,
            "play_pause_pin_number": 5,
        },
        "spotify": {
            "username": "******",
            "password": "******",
            "bitrate": 160,
            "volume_normalization": True,
            "private_session": False,
            "timeout": 10,
            "allow_cache": True,
            "allow_network": True,
            "allow_playlists": True,
            "search_album_count": 20,
            "search_artist_count": 10,
            "search_track_count": 50,
            "toplist_countries": ["GB", "US"],
            "client_id": "abcd1234",
            "client_secret": "YWJjZDEyMzQ=",
        },
    }

    monkeypatch.setattr(os, "system", mock_system)
    Device.pin_factory = MockFactory()
    mixer = dummy_mixer.create_proxy()
    audio = dummy_audio.create_proxy()
    backend = dummy_backend.create_proxy(audio=audio)
    core = mopidy_core.Core.start(audio=audio, mixer=mixer,
                                  backends=[backend]).proxy()
    return frontend_lib.ChoosMoosFrontend(config, core)
Beispiel #17
0
def audio():
    actor = dummy_audio.create_proxy()
    yield actor
    actor.stop()