示例#1
0
    def test_set_options_triggered_on_core_events(self):
        with mock.patch.object(PandoraFrontend, 'set_options',
                               mock.Mock()) as set_options_mock:

            tl_tracks = self.core.tracklist.get_tl_tracks().get()
            core_events = {
                'track_playback_started': {
                    'tl_track': tl_tracks[0]
                },
                'track_playback_ended': {
                    'tl_track': tl_tracks[0],
                    'time_position': 100
                },
                'track_playback_paused': {
                    'tl_track': tl_tracks[0],
                    'time_position': 100
                },
                'track_playback_resumed': {
                    'tl_track': tl_tracks[0],
                    'time_position': 100
                },
            }

            self.core.playback.play(tlid=self.tl_tracks[0].tlid)

            for (event, kwargs) in core_events.items():
                self.frontend.setup_required = True
                listener.send(CoreListener, event, **kwargs)
                self.replay_events()
                self.assertEqual(set_options_mock.called, True,
                                 "Setup not done for event '{}'".format(event))
                set_options_mock.reset_mock()
 def test_options_changed_triggers_setup(self, mopidy):
     with mock.patch.object(PandoraFrontend, 'set_options', mock.Mock()) as set_options_mock:
         mopidy.core.playback.play(tlid=mopidy.tl_tracks[0].tlid).get()
         mopidy.frontend.setup_required = False
         listener.send(CoreListener, 'options_changed')
         mopidy.replay_events()
         assert set_options_mock.called
示例#3
0
    def test_set_options_triggered_on_core_events(self, mopidy):
        with mock.patch.object(PandoraFrontend, 'set_options',
                               mock.Mock()) as set_options_mock:
            tl_tracks = mopidy.core.tracklist.get_tl_tracks().get()
            core_events = {
                'track_playback_started': {
                    'tl_track': tl_tracks[0]
                },
                'track_playback_ended': {
                    'tl_track': tl_tracks[0],
                    'time_position': 100
                },
                'track_playback_paused': {
                    'tl_track': tl_tracks[0],
                    'time_position': 100
                },
                'track_playback_resumed': {
                    'tl_track': tl_tracks[0],
                    'time_position': 100
                },
            }

            mopidy.core.playback.play(tlid=mopidy.tl_tracks[0].tlid)

            for (event, kwargs) in core_events.items():
                mopidy.frontend.setup_required = True
                listener.send(CoreListener, event, **kwargs)
                mopidy.replay_events()
                assert set_options_mock.called is True
                set_options_mock.reset_mock()
示例#4
0
 def test_options_changed_triggers_setup(self):
     with mock.patch.object(PandoraFrontend, 'set_options',
                            mock.Mock()) as set_options_mock:
         self.core.playback.play(tlid=self.tl_tracks[0].tlid).get()
         self.frontend.setup_required = False
         listener.send(CoreListener, 'options_changed')
         self.replay_events()
         assert set_options_mock.called
示例#5
0
 def test_options_changed_triggers_setup(self, mopidy):
     with mock.patch.object(PandoraFrontend, "set_options",
                            mock.Mock()) as set_options_mock:
         mopidy.core.playback.play(tlid=mopidy.tl_tracks[0].tlid).get()
         mopidy.frontend.setup_required = False
         listener.send(CoreListener, "options_changed")
         mopidy.replay_events()
         assert set_options_mock.called
    def test_delete_station_clears_tracklist_on_finish(self, mopidy_with_monitor):
        mopidy_with_monitor.core.playback.play(tlid=mopidy_with_monitor.tl_tracks[0].tlid)
        mopidy_with_monitor.replay_events()
        assert len(mopidy_with_monitor.core.tracklist.get_tl_tracks().get()) > 0

        listener.send(PandoraBackendListener, 'event_processed',
                      track_uri=mopidy_with_monitor.tracks[0].uri,
                      pandora_event='delete_station')
        mopidy_with_monitor.replay_events()

        assert len(mopidy_with_monitor.core.tracklist.get_tl_tracks().get()) == 0
示例#7
0
    def test_delete_station_clears_tracklist_on_finish(self):
        self.core.playback.play(tlid=self.tl_tracks[0].tlid)
        self.replay_events()
        assert len(self.core.tracklist.get_tl_tracks().get()) > 0

        listener.send(PandoraBackendListener,
                      'event_processed',
                      track_uri=self.tracks[0].uri,
                      pandora_event='delete_station')
        self.replay_events()

        assert len(self.core.tracklist.get_tl_tracks().get()) == 0
    def track_playback_ended(self, tl_track, time_position):
        track = tl_track.track

        duration = track.length and track.length // 1000 or 0
        time_position = time_position // 1000

        if time_position < duration // 2 and time_position < 240:
            logger.debug(
                'Track not played long enough too scrobble. (50% or 240s)')
            return

        track_id = track.uri.rsplit(':')[-1]
        logger.debug('Increasing play count: %s', track_id)
        listener.send(GMusicScrobblerListener,
                      'increment_song_playcount',
                      track_id=track_id)
示例#9
0
    def test_delete_station_clears_tracklist_on_finish(self,
                                                       mopidy_with_monitor):
        mopidy_with_monitor.core.playback.play(
            tlid=mopidy_with_monitor.tl_tracks[0].tlid)
        mopidy_with_monitor.replay_events()
        assert len(
            mopidy_with_monitor.core.tracklist.get_tl_tracks().get()) > 0

        listener.send(PandoraBackendListener,
                      'event_processed',
                      track_uri=mopidy_with_monitor.tracks[0].uri,
                      pandora_event='delete_station')
        mopidy_with_monitor.replay_events()

        assert len(
            mopidy_with_monitor.core.tracklist.get_tl_tracks().get()) == 0
示例#10
0
    def track_playback_ended(self, tl_track, time_position):
        track = tl_track.track

        duration = track.length and track.length // 1000 or 0
        time_position = time_position // 1000

        if time_position < duration // 2 and time_position < 240:
            logger.debug(
                'Track not played long enough too scrobble. (50% or 240s)')
            return

        track_id = track.uri.rsplit(':')[-1]
        logger.debug('Increasing play count: %s', track_id)
        listener.send(
            GMusicScrobblerListener,
            'increment_song_playcount', track_id=track_id)
示例#11
0
    def test_set_options_triggered_on_core_events(self, mopidy):
        with mock.patch.object(PandoraFrontend, 'set_options', mock.Mock()) as set_options_mock:
            tl_tracks = mopidy.core.tracklist.get_tl_tracks().get()
            core_events = {
                'track_playback_started': {'tl_track': tl_tracks[0]},
                'track_playback_ended': {'tl_track': tl_tracks[0], 'time_position': 100},
                'track_playback_paused': {'tl_track': tl_tracks[0], 'time_position': 100},
                'track_playback_resumed': {'tl_track': tl_tracks[0], 'time_position': 100},
            }

            mopidy.core.playback.play(tlid=mopidy.tl_tracks[0].tlid)

            for (event, kwargs) in core_events.items():
                mopidy.frontend.setup_required = True
                listener.send(CoreListener, event, **kwargs)
                mopidy.replay_events()
                assert set_options_mock.called is True
                set_options_mock.reset_mock()
示例#12
0
    def track_playback_ended(self, tl_track, time_position):
        if self.scrobbling:
            track = tl_track.track
            if track.uri.startswith("ytmusic:"):
                duration = track.length and track.length // 1000 or 0
                time_position = time_position // 1000

                if time_position < duration // 2 and time_position < 120:
                    logger.debug(
                        "Track not played long enough too scrobble. (50% or 120s)"
                    )
                    return

                bId = track.uri.split(":")[2]
                logger.debug("Scrobbling: %s", bId)
                listener.send(
                    YTMusicScrobbleListener,
                    "scrobble_track",
                    bId=bId,
                )
示例#13
0
 def send(event, **kwargs):
     """Helper to allow calling of audio listener events"""
     listener.send(AudioListener, event, **kwargs)
示例#14
0
 def change_track(self, track):
     listener.send(PandoraPlaybackListener, 'track_changing', track=track)
     return super(DummyPandoraPlaybackProviderWithAudioEvents,
                  self).change_track(track)
示例#15
0
 def send(event, **kwargs):
     """Helper to allow calling of mixer listener events"""
     listener.send(MixerListener, event, **kwargs)
示例#16
0
文件: mixer.py 项目: zwl1671/mopidy
 def send(event, **kwargs):
     """Helper to allow calling of mixer listener events"""
     listener.send(MixerListener, event, **kwargs)
示例#17
0
 def send(event, **kwargs):
     listener.send(PandoraBackendListener, event, **kwargs)
示例#18
0
 def change_track(self, track):
     listener.send(PandoraPlaybackListener, "track_changing", track=track)
     return super().change_track(track)
示例#19
0
 def send_idle(self, subsystem):
     if subsystem:
         listener.send(session.MpdSession, subsystem)
示例#20
0
文件: backend.py 项目: mopidy/mopidy
 def send(event, **kwargs):
     """Helper to allow calling of backend listener events"""
     listener.send(BackendListener, event, **kwargs)
示例#21
0
 def send(event, **kwargs):
     # Sends events to the EventListener for processing
     listener.send(JellyfinPlaybackListener, event, **kwargs)
示例#22
0
 def send(event, **kwargs):
     """Helper to allow calling of audio listener events"""
     listener.send(AudioListener, event, **kwargs)
示例#23
0
 def change_track(self, track):
     listener.send(PandoraPlaybackListener, 'track_changing', track=track)
     return super(DummyPandoraPlaybackProviderWithAudioEvents, self).change_track(track)
示例#24
0
 def send_idle(self, subsystem):
     if subsystem:
         listener.send(session.MpdSession, subsystem)
示例#25
0
 def send(event, **kwargs):
     """Helper to allow calling of core listener events"""
     listener.send(CoreListener, event, **kwargs)
示例#26
0
 def send(event, **kwargs):
     listener.send(EventMonitorListener, event, **kwargs)
示例#27
0
 def send(event, **kwargs):
     """Helper to allow calling of core listener events"""
     listener.send(CoreListener, event, **kwargs)
示例#28
0
 def send(event, **kwargs):
     listener.send(PandoraFrontendListener, event, **kwargs)
示例#29
0
 def send(event, **kwargs):
     """Helper to allow calling of backend listener events"""
     listener.send(BackendListener, event, **kwargs)
示例#30
0
 def send(event, **kwargs):
     listener.send(PandoraPlaybackListener, event, **kwargs)