Exemplo n.º 1
0
    def test_events_triggered_on_triple_click_action(self, config,
                                                     mopidy_with_monitor):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            # Pause -> Resume -> Pause
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[0].tlid)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.seek(100)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.pause()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.resume()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.pause().get()
            mopidy_with_monitor.replay_events(until="event_triggered")

            thread_joiner.wait(timeout=1.0)
            call = mock.call(
                EventMonitorListener,
                "event_triggered",
                track_uri=mopidy_with_monitor.tl_tracks[0].track.uri,
                pandora_event=config["pandora"]["on_pause_resume_pause_click"],
            )

            assert call in mopidy_with_monitor.send_mock.mock_calls
Exemplo n.º 2
0
    def test_changing_track_station_changed(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            self.core.tracklist.clear()
            self.core.tracklist.add(uris=[
                self.tl_tracks[0].track.uri, self.tl_tracks[4].track.uri
            ])
            tl_tracks = self.core.tracklist.get_tl_tracks().get()
            assert len(tl_tracks) == 2

            self.core.playback.play(tlid=tl_tracks[0].tlid)
            self.replay_events()
            self.core.playback.seek(100)
            self.replay_events()
            self.core.playback.next()

            self.replay_events(until='end_of_tracklist_reached')

            thread_joiner.wait(
                timeout=1.0
            )  # Wait until threads spawned by frontend have finished.

            tl_tracks = self.core.tracklist.get_tl_tracks().get()
            assert len(
                tl_tracks) == 1  # Tracks were trimmed from the tracklist
            # Only the track recently changed to is left in the tracklist
            assert tl_tracks[0].track.uri == self.tl_tracks[4].track.uri

            call = mock.call(PandoraFrontendListener,
                             'end_of_tracklist_reached',
                             station_id='id_mock_other',
                             auto_play=False)

            assert call in self.send_mock.mock_calls
Exemplo n.º 3
0
    def test_monitor_ignores_ads(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            self.core.playback.play(tlid=self.tl_tracks[2].tlid)
            self.core.playback.seek(100)
            self.core.playback.pause()
            self.replay_events()
            self.core.playback.resume().get()
            self.replay_events(until='track_playback_resumed')

            thread_joiner.wait(timeout=1.0)
            assert self.events.qsize(
            ) == 0  # Check that no events were triggered
Exemplo n.º 4
0
    def test_monitor_ignores_ads(self, mopidy_with_monitor):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[2].tlid)
            mopidy_with_monitor.core.playback.seek(100)
            mopidy_with_monitor.core.playback.pause()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.resume().get()
            mopidy_with_monitor.replay_events(until="track_playback_resumed")

            thread_joiner.wait(timeout=1.0)
            assert (mopidy_with_monitor.events.qsize() == 0
                    )  # Check that no events were triggered
Exemplo n.º 5
0
    def test_detect_track_change_no_op(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            # Next
            self.core.playback.play(tlid=self.tl_tracks[0].tlid)
            self.replay_events()
            self.core.playback.seek(100)
            self.replay_events()
            self.core.playback.stop()
            self.replay_events()
            self.core.playback.play(tlid=self.tl_tracks[0].tlid).get()
            self.replay_events(until='track_playback_started')

            thread_joiner.wait(timeout=1.0)
            assert self.events.empty()
Exemplo n.º 6
0
    def test_station_change_does_not_trim_currently_playing_track_from_tracklist(
            self, mopidy):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            with mock.patch.object(PandoraFrontend, 'is_station_changed',
                                   mock.Mock(return_value=True)):
                mopidy.core.playback.play(tlid=mopidy.tl_tracks[4].tlid)
                mopidy.replay_events()

                thread_joiner.wait(
                    timeout=1.0
                )  # Wait until threads spawned by frontend have finished.

                tl_tracks = mopidy.core.tracklist.get_tl_tracks().get()
                assert len(tl_tracks) == 1
                assert tl_tracks[0].track == mopidy.tl_tracks[4].track
Exemplo n.º 7
0
    def test_monitor_resumes_playback_after_event_trigger(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            self.core.playback.play(tlid=self.tl_tracks[0].tlid)
            self.replay_events()
            self.core.playback.seek(100)
            self.replay_events()
            self.core.playback.pause()
            self.replay_events()
            assert self.core.playback.get_state().get() == PlaybackState.PAUSED

            self.core.playback.next().get()
            self.replay_events()

            thread_joiner.wait(timeout=5.0)
            assert self.core.playback.get_state().get(
            ) == PlaybackState.PLAYING
Exemplo n.º 8
0
    def test_changing_track_no_op(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            self.core.playback.play(tlid=self.tl_tracks[0].tlid)
            self.core.playback.next()

            assert len(self.core.tracklist.get_tl_tracks().get()) == len(
                self.tl_tracks)
            self.replay_events()

            thread_joiner.wait(
                timeout=1.0
            )  # Wait until threads spawned by frontend have finished.

            assert len(self.core.tracklist.get_tl_tracks().get()) == len(
                self.tl_tracks)
            assert self.events.qsize() == 0
Exemplo n.º 9
0
    def test_detect_track_change_no_op(self, mopidy_with_monitor):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            # Next
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[0].tlid)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.seek(100)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.stop()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[0].tlid).get()
            mopidy_with_monitor.replay_events(until='track_playback_started')

            thread_joiner.wait(timeout=1.0)
            assert mopidy_with_monitor.events.empty()
Exemplo n.º 10
0
    def test_detect_track_change_previous(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            # Next
            self.core.playback.play(tlid=self.tl_tracks[0].tlid)
            self.replay_events()
            self.core.playback.seek(100)
            self.replay_events()
            self.core.playback.previous().get()
            self.replay_events(until='track_changed_previous')

            thread_joiner.wait(timeout=1.0)
            call = mock.call(EventMonitorListener,
                             'track_changed_previous',
                             old_uri=self.tl_tracks[0].track.uri,
                             new_uri=self.tl_tracks[0].track.uri)

            assert call in self.send_mock.mock_calls
Exemplo n.º 11
0
    def test_set_options_performs_auto_setup(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            assert self.frontend.setup_required.get()
            self.core.tracklist.set_repeat(True)
            self.core.tracklist.set_consume(False)
            self.core.tracklist.set_random(True)
            self.core.tracklist.set_single(True)
            self.core.playback.play(tlid=self.tl_tracks[0].tlid).get()
            self.replay_events()

            thread_joiner.wait(timeout=1.0)

            assert self.core.tracklist.get_repeat().get() is False
            assert self.core.tracklist.get_consume().get() is True
            assert self.core.tracklist.get_random().get() is False
            assert self.core.tracklist.get_single().get() is False
            self.replay_events()

            assert not self.frontend.setup_required.get()
Exemplo n.º 12
0
    def test_events_triggered_on_resume_action(self):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            # Pause -> Resume
            self.core.playback.play(tlid=self.tl_tracks[0].tlid)
            self.replay_events()
            self.core.playback.seek(100)
            self.replay_events()
            self.core.playback.pause()
            self.replay_events()
            self.core.playback.resume().get()
            self.replay_events(until='event_triggered')

            thread_joiner.wait(timeout=1.0)
            call = mock.call(EventMonitorListener,
                             'event_triggered',
                             track_uri=self.tl_tracks[0].track.uri,
                             pandora_event=conftest.config()['pandora']
                             ['on_pause_resume_click'])

            assert call in self.send_mock.mock_calls
Exemplo n.º 13
0
    def test_detect_track_change_previous(self, mopidy_with_monitor):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            # Next
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[0].tlid)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.seek(100)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.previous().get()
            mopidy_with_monitor.replay_events(until="track_changed_previous")

            thread_joiner.wait(timeout=1.0)
            call = mock.call(
                EventMonitorListener,
                "track_changed_previous",
                old_uri=mopidy_with_monitor.tl_tracks[0].track.uri,
                new_uri=mopidy_with_monitor.tl_tracks[0].track.uri,
            )

            assert call in mopidy_with_monitor.send_mock.mock_calls
Exemplo n.º 14
0
    def test_detect_track_change_next_from_paused(self, mopidy_with_monitor):
        with conftest.ThreadJoiner(timeout=5.0) as thread_joiner:
            # Next
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[0].tlid)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.seek(100)
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.pause()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.next().get()
            mopidy_with_monitor.replay_events(until='track_changed_next')

            thread_joiner.wait(timeout=5.0)
            call = mock.call(
                EventMonitorListener,
                'track_changed_next',
                old_uri=mopidy_with_monitor.tl_tracks[0].track.uri,
                new_uri=mopidy_with_monitor.tl_tracks[1].track.uri)

            assert call in mopidy_with_monitor.send_mock.mock_calls
Exemplo n.º 15
0
    def test_events_triggered_on_previous_action(self, config,
                                                 mopidy_with_monitor):
        with conftest.ThreadJoiner(timeout=5.0) as thread_joiner:
            # Pause -> Previous
            mopidy_with_monitor.core.playback.play(
                tlid=mopidy_with_monitor.tl_tracks[0].tlid).get()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.seek(100).get()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.pause().get()
            mopidy_with_monitor.replay_events()
            mopidy_with_monitor.core.playback.previous().get()
            mopidy_with_monitor.replay_events(until='event_triggered')

            thread_joiner.wait(timeout=5.0)
            call = mock.call(
                EventMonitorListener,
                'event_triggered',
                track_uri=mopidy_with_monitor.tl_tracks[0].track.uri,
                pandora_event=config['pandora']['on_pause_previous_click'])

            assert call in mopidy_with_monitor.send_mock.mock_calls
Exemplo n.º 16
0
    def test_changing_track_station_changed(self, mopidy):
        with conftest.ThreadJoiner(timeout=1.0) as thread_joiner:
            mopidy.core.tracklist.clear()
            mopidy.core.tracklist.add(uris=[
                mopidy.tl_tracks[0].track.uri,
                mopidy.tl_tracks[4].track.uri,
            ])
            tl_tracks = mopidy.core.tracklist.get_tl_tracks().get()
            assert len(tl_tracks) == 2

            mopidy.core.playback.play(tlid=tl_tracks[0].tlid)
            mopidy.replay_events()
            mopidy.core.playback.seek(100)
            mopidy.replay_events()
            mopidy.core.playback.next()

            mopidy.replay_events(until="end_of_tracklist_reached")

            thread_joiner.wait(
                timeout=1.0
            )  # Wait until threads spawned by frontend have finished.

            tl_tracks = mopidy.core.tracklist.get_tl_tracks().get()
            assert len(
                tl_tracks) == 1  # Tracks were trimmed from the tracklist
            # Only the track recently changed to is left in the tracklist
            assert tl_tracks[0].track.uri == mopidy.tl_tracks[4].track.uri

            call = mock.call(
                PandoraFrontendListener,
                "end_of_tracklist_reached",
                station_id="id_mock_other",
                auto_play=False,
            )

            assert call in mopidy.send_mock.mock_calls