-
Notifications
You must be signed in to change notification settings - Fork 13
Add missing property changes #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
df86098
12320db
cb91aeb
00acbd7
5b772a6
6c1815d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,9 +91,7 @@ def PlayPause(self): | |
| state = self.core.playback.get_state().get() | ||
| if state == PlaybackState.PLAYING: | ||
| self.core.playback.pause().get() | ||
| elif state == PlaybackState.PAUSED: | ||
| self.core.playback.resume().get() | ||
| elif state == PlaybackState.STOPPED: | ||
| else: | ||
| self.core.playback.play().get() | ||
|
Comment on lines
+94
to
95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I don't remember how this works. Will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems so, https://docs.mopidy.com/stable/_modules/mopidy/core/playback/#PlaybackController.play elif tl_track is None and self.get_state() == PlaybackState.PAUSED:
self.resume()
return |
||
|
|
||
| def Stop(self): | ||
|
|
@@ -108,11 +106,7 @@ def Play(self): | |
| if not self.CanPlay: | ||
| logger.debug("%s.Play not allowed", self.INTERFACE) | ||
| return | ||
| state = self.core.playback.get_state().get() | ||
| if state == PlaybackState.PAUSED: | ||
| self.core.playback.resume().get() | ||
| else: | ||
| self.core.playback.play().get() | ||
| self.core.playback.play().get() | ||
|
|
||
| def Seek(self, offset): | ||
| logger.debug("%s.Seek called", self.INTERFACE) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ requires = ["setuptools >= 30.3.0", "wheel"] | |
|
|
||
|
|
||
| [tool.black] | ||
| target-version = ["py37", "py38"] | ||
| target-version = ["py37", "py38", "py39", "py310"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cherry-picked the Python 3.10 commit to |
||
| line-length = 80 | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| class DictFields: | ||
| """Asserts all required key-value pairs of the dict match. | ||
|
|
||
| assert DictFields({"a": 1}) == {"a": 1, "b": 5} | ||
| assert DictFields({"a": 1}) != {"a": 2} | ||
| """ | ||
|
|
||
| def __init__(self, required: dict): | ||
| self.required = required | ||
|
|
||
| def __eq__(self, other: dict) -> bool: | ||
| return {**other, **self.required} == other | ||
|
|
||
| def __repr__(self) -> str: | ||
| return f"DictFields({self.required.__repr__()})" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from time import sleep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from unittest.mock import call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import pytest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from mopidy.models import Track | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import mopidy_mpris | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from . import DictFields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def player_call(can_play, can_go_next, can_go_previous): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vals = DictFields( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "CanPlay": can_play, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "CanGoNext": can_go_next, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "CanGoPrevious": can_go_previous, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return call("org.mpris.MediaPlayer2.Player", vals, []) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def assert_called(can_play, can_go_next, can_go_previous): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Beware the multithreading! Wait for the signal to get emitted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep(0.1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mopidy_mpris.interface.Interface.PropertiesChanged.assert_has_calls( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [player_call(can_play, can_go_next, can_go_previous)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mopidy_mpris.interface.Interface.PropertiesChanged.reset_mock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+29
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would read better with
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_cold_start(frontend, core, player): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert not player.CanPlay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert not player.CanGoNext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert not player.CanGoPrevious | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| core.tracklist.add([Track(uri="dummy:a"), Track(uri="dummy:b")]).get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_called(True, True, False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_tracklist_full_to_empty(frontend, core, player): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| core.tracklist.add([Track(uri="dummy:a"), Track(uri="dummy:b")]).get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_called(True, True, False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| core.tracklist.clear().get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_called(False, False, False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_tracklist_changed_empty_while_playing(frontend, core, player): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| core.tracklist.add([Track(uri="dummy:a")]).get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_called(True, True, False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| core.playback.play().get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_called(True, True, True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| core.tracklist.clear().get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_called(False, False, False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.parametrize("frontend", ["fail"], indirect=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_frontend_fail_stops_actor(frontend): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep(0.1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert not frontend.actor_ref.is_alive() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to note that this will change the output from something short like e.g. "MPRIS frontend setup failed (unable to bind to port)" to a full stack trace.
I don't remember the typical errors here, so I guess this is OK.