Commit graph

8614 commits

Author SHA1 Message Date
Carl Suster
a4fe6875a1 bpd: fix bug in bounds check of current song index
The songs are indexed starting from zero for the play command, however
the bound check was off by one. An index matching the length of the
playlist would crash the server instead of responding with an error
message over the protocol.
2019-04-01 17:41:25 +11:00
Carl Suster
0c3a63ef9f bpd: fix repeat mode behaviour
The repeat flag indicates that the entire playlist should be repeated.
If both the repeat and single flags are set then this triggers the old
behaviour of looping over a single track.
2019-04-01 17:39:35 +11:00
Carl Suster
b245c0e755 bpd: test fields returned by status command 2019-04-01 16:42:39 +11:00
Carl Suster
bae9c40600 bpd: support the single command
This command instructs bpd to stop playing when the current song
finishes. In the MPD 0.20 protocol this flag gains a value 'oneshot' but
for now we just support its older version with a boolean value.
2019-04-01 16:30:02 +11:00
Carl Suster
71e7621642 bpd: no-op support for persistent playlists
The real MPD offers persistent playlist manipulation, storing the
playlists in a directory set in the config file. If that directory is
not available then the feature is disabled and the relevant commands all
respond with errors. Based on this, the initial support in bpd just
returns errors matching the MPD server in the disabled mode.

For playlistadd, extend the _bpd_add helper to work with playlists other
than the queue in order to support testing the real implementations of
these commands in the future.
2019-04-01 16:30:02 +11:00
Carl Suster
859e16d1e3 bpd: support consume command 2019-04-01 16:30:02 +11:00
Carl Suster
e5851866d7 bpd: add replay_gain_* commands
There's a special status command for checking the replay gain mode,
which can be set to one of a short list of possible values. For now at
least we can ignore this feature, but track the setting anyway.
2019-04-01 14:49:27 +11:00
Carl Suster
67a0b38d20 bpd: add dummy command for volume
MPD supports a deprecated command 'volume' which was used to change the
volume by a relative amount unlike its replacement 'setvol' which uses
an absolute amount. As far as I can tell 'volume' always responds with a system
error message "No mixer".
2019-04-01 14:49:27 +11:00
Carl Suster
1511e313f7 bpd: add mixramp commands
These are a more sophisticated version of crossfade so we're free to
ignore them, at least for now. We now track the values of the two
settings, and show them in the status output. Like MPD, we suppress the
mixrampdb value if it's set to nan, which is how it signals that the
feature should be turned off.
2019-04-01 14:49:27 +11:00
Carl Suster
0f53ae9a87 bpd: error instead of crashing on extra argument
If an MPC client is expecting a command to take an argument that bpd
isn't expecting (e.g. because of a difference in protocol versions) then
bpd currently crashes completely. Instead, do what the real MPD does and
return an error message over the protocol.
2019-04-01 14:49:27 +11:00
Carl Suster
d94a5393b2 bpd: fix crossfade command
Although crossfade is not implemented in bpd, we can store the setting
and repeat is back to clients. Also log a warning that the operation is
not implemented.

The real MPD doesn't show the crossfade in status if it's zero since
that means no crossfade, so now we don't either.
2019-04-01 14:49:27 +11:00
Carl Suster
de6718abdf bpd: separate tests by command category 2019-04-01 14:49:27 +11:00
Adrian Sampson
422189ca3d Changelog for #3202 2019-03-31 22:06:01 -04:00
Adrian Sampson
b318f6fe58 Merge pull request #3202 from jackwilsdon/fix-3.8
Support Python 3.8 (fixes #3201)
2019-03-31 22:05:17 -04:00
Adrian Sampson
6c9c881989 Changelog for #3089 2019-03-31 21:52:30 -04:00
Adrian Sampson
a588784dc7 Merge pull request #3089 from pprkut/delayed_type_casting
Performance improvement: Type cast properties on demand
2019-03-31 21:51:34 -04:00
Adrian Sampson
1382f02caa
Merge pull request #3198 from arcresu/test-ui-pytest
Fix test_ui:test_version under pytest
2019-03-31 21:48:52 -04:00
Adrian Sampson
c74a7059b4 Merge pull request #3192 from translit/yaml-safe-load
Fix PyYAML yaml.load(input) Deprecation
2019-03-31 21:46:29 -04:00
Adrian Sampson
a1f965a3e5 Changelog for #3197 2019-03-31 21:45:08 -04:00
Adrian Sampson
0208ec69ef Merge pull request #3197 from arcresu/deprecation
Fix several deprecation warnings
2019-03-31 21:44:37 -04:00
Adrian Sampson
0d31b33948 Changelog for #3196 2019-03-31 21:42:16 -04:00
Adrian Sampson
0042f3205e Merge pull request #3196 from arcresu/bpd-log
bpd: use plugin logger instead of global logger
2019-03-31 21:41:22 -04:00
Adrian Sampson
3701d145b0 Changelog for #3195 2019-03-31 21:39:55 -04:00
Adrian Sampson
fa3a569a45 Merge pull request #3195 from arcresu/patch-1
the: log a debug only when text is changed
2019-03-31 21:39:13 -04:00
Jack Wilsdon
8df213e9b6
Support Python 3.8 (fixes #3201) 2019-03-31 18:26:22 +01:00
Carl Suster
b4c4f3ca19 bpd: use plugin logger instead of global logger 2019-03-31 22:06:43 +11:00
Heinz Wiesinger
f9f2bddba0 Add class wrapper for lazily converting attributes 2019-03-31 11:58:16 +02:00
Carl Suster
bed89df69a Fix test_ui:test_version under pytest
The test `CommonOptionsParserCliTest.test_version` was passing with nose
but failing with pytest (see output below). The reason for the failure
seemed to be that the `test` plugin was loaded when it wasn't expected
to be loaded, changing the output of the `version` command. I'm not sur
exactly why that was happening, but since that test already inherited
from `TestHelper`, just invoking the plugin load/unload helper was
enough to fix it. I also removed the line setting the `self.lib`
variable since that's already done in the helper.

---

self = <test.test_ui.CommonOptionsParserCliTest testMethod=test_version>

    def test_version(self):
        l = self.run_with_output(u'version')
        self.assertIn(u'Python version', l)
>       self.assertIn(u'no plugins loaded', l)
E       AssertionError: 'no plugins loaded' not found in 'beets version 1.4.8\nPython version 3.7.3rc1\nplugins: test\n'

test/test_ui.py:1292: AssertionError
2019-03-31 20:22:44 +11:00
Carl Suster
a6305c36e1 Fix deprecated plistlib function
https://docs.python.org/3.7/library/plistlib.html#plistlib.readPlist
2019-03-31 19:53:17 +11:00
Carl Suster
e4c03fd63f Fix deprecated placement of inline regex flags
https://bugs.python.org/issue22493
2019-03-31 19:44:49 +11:00
Carl Suster
3997141250 Fix deprecated imports from collections for Py3
Since Python 3.3 the abstract base classes from `collections` are moved
to the `collections.abc` module. From Python 3.8 they will be
unavailable from their original location.

https://docs.python.org/3/library/collections.abc.html
2019-03-31 19:44:49 +11:00
Carl Suster
ca60555ffa Fix deprecated call log.warn -> log.warning
https://bugs.python.org/issue13235
2019-03-31 19:44:40 +11:00
Carl Suster
7557bb06d6 bpd: use log instead of stdout 2019-03-31 18:43:18 +11:00
Carl Suster
0b4293de6e
the: log a debug only when text is changed
Previously the `the` plugin would log a debug message when the text _didn't_ get changed by the plugin, whereas I think what was intended was the opposite. With this change the logged messages show the actual transformations made by the plugin.
2019-03-31 18:19:09 +11:00
Adrian Sampson
728267d06c
Merge pull request #3190 from arcresu/bpd
Add tests for BPD
2019-03-30 21:25:27 -04:00
Carl Suster
999cf14401 BPD tests: change expectedFailure -> skip for nose 2019-03-31 10:50:42 +11:00
Carl Suster
2e35c27dce BPD tests: improve helpers 2019-03-31 10:46:14 +11:00
Carl Suster
eb5c7513a1 BPD tests: fix GstPlayer mock 2019-03-31 10:46:14 +11:00
Carl Suster
2a2d9b5c98 BPD tests: explicitly close client socket 2019-03-31 10:46:14 +11:00
Carl Suster
a6c976b880 BPD tests: small code reformatting 2019-03-31 10:46:14 +11:00
Carl Suster
3eaf0f7a19 BPD tests: use canonical capitalisation of tags 2019-03-31 10:46:14 +11:00
Carl Suster
4c627cbacb [skip travis] BPD tests: add items by path 2019-03-31 10:46:14 +11:00
Carl Suster
dfc5da70cd BPD tests: avoid os.fsdecode new in Py3.2 2019-03-31 10:46:14 +11:00
Carl Suster
14d0cc3b85 BPD tests: be more careful with paths 2019-03-31 10:46:14 +11:00
Carl Suster
7c8bbd3011 BPD tests: avoid Py3.7-only mp.Process.kill 2019-03-31 10:46:14 +11:00
Carl Suster
35bf041ad0 BPD tests: fork and launch beets 2019-03-31 10:46:14 +11:00
Carl Suster
c42c0c06bc BPD tests: fix CI failures 2019-03-31 10:46:14 +11:00
Carl Suster
2286c0ce7b BPD tests: run bpd in a subprocess 2019-03-31 10:46:14 +11:00
Carl Suster
767441d5d5 BPD tests: improve test helpers
Decode the bytes to strings: the MPD protocol specifies that the
communications are all in UTF-8.

Also parse the body into a dict since this is typically more convenient
than having to do it manually in each test.
2019-03-31 10:46:14 +11:00
Carl Suster
d9537f27dc BPD tests: fix CI failures 2019-03-31 10:46:14 +11:00