Commit Graph
2074 Commits
Author SHA1 Message Date
Carl Suster 4be2e1b5e6 Remove beets.util.inspect wrapper 2019-04-02 10:22:47 +11:00
Carl Suster e839e4ea19 bpd: improve exception handling
Check function signature instead of using TypeError to crudely guess
that the wrong number of arguments were provided.

Prevent bpd from crashing when trying to log a traceback. The
`traceback.format_exc` function takes an optional argument which is
supposed to be an integer restricting the length of the backtrace to
show. Instead we were passing the exception object to this function and
causing a new exception to be raised.
2019-04-02 09:39:07 +11:00
Carl Suster 146c5f5e13 bpd: fix repeat, consume and single in reverse
These flags are all relevant to the 'previous' command as well as the
'next' command.
2019-04-01 18:05:10 +11:00
Carl Suster 12e49b3c88 bpd: skipping backwards through zero keeps playing
Previously issuing the 'previous' command when at position 0 on the
playlist would cause bpd to stop playing. MPD instead just restarts the
currently playing song instead, so we now match this behaviour.
2019-04-01 17:51:21 +11:00
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
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 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
Carl Suster 76221428f8 Add a DummyIn::close no-op implementation
The BOD tests are currently forking a process with a server running, and
this attempts to close stdin. Tests were failing due to DummyIn not
implementing the close() method. Adding this simple no-op does the trick
to allow forking and seems like a harmless addition.
2019-03-31 10:46:14 +11:00
Carl Suster 5d2b883b72 BPD tests: test several simple commands 2019-03-31 10:46:14 +11:00
Carl Suster 7302cd6ab5 BPD tests: test helper for BPD batch commands
The MPD protocol allows batching commands. There are two choices for the
first message that announced a batch is starting, and we just go for the
one that causes the server to respond with a marker message between each
individual response, since that's easier. This might need to be tweaked
in order to test the behaviour with the other batch indicator.
2019-03-31 10:46:14 +11:00
Carl Suster 9a5be1f971 BPD tests: test supported tag types
MPD now supports more fields ("tags") than what BPD advertises. Fixing
this should be a simple task of extending the mapping of fields to tags
in BPD's implementation.
2019-03-31 10:46:14 +11:00
Carl Suster acd66ce560 BPD tests: run BPD Server with a fake gstplayer 2019-03-31 10:46:14 +11:00
Carl Suster acc3f3efb0 BPD tests: check all specified commands known
The current MPD spec is several versions ahead of BPD. These tests just
compare the full specified list of commands against what BPD claims to
support (without actually testing their implementations). It's handy as
a measure of progress against the specification, but can perhaps be
dropped later once all of the individual protocol methods have tests.
2019-03-31 10:46:14 +11:00
Carl Suster 59e66aaa7f BPD tests: password command 2019-03-31 10:46:14 +11:00
Carl Suster 078c583434 BPD tests: add basic test framework
A simple TCP client wraps the low level protocol to allow testing of the
BPD server as a black box.
2019-03-31 10:46:14 +11:00
jroitgrund@gmail.com ea307f62d1 Don't move album art twice 2019-03-27 01:41:42 +00:00
Jack Wilsdon 25549a656f Add test for interpolating byte strings in hook plugin 2019-02-25 14:42:20 +00:00
Adrian Sampson 81c5ae3fdf Merge pull request #3151 from Holzhaus/playlist-plugin-additions
playlist: Add auto-update functionality and more tests
2019-02-18 08:40:55 -05:00
Jan Holthuis 76a3e44aad test: Make music dir of playlist tests Windows-compatible 2019-02-17 21:27:37 +01:00
Jan Holthuis 7ec55a5f3b test: Use unicode literals for library queries in playlist tests 2019-02-17 21:27:09 +01:00
Jan Holthuis a9dd5a7cdc test: Add testcase for playlist plugin's update functionality 2019-02-17 20:31:15 +01:00
Adrian Sampson 7edba6e9ea Fix test harness for named queries 2019-02-17 14:11:40 -05:00
Jan Holthuis 1af82cc450 test: Split up playlist test helper class 2019-02-17 19:41:37 +01:00
Adrian Sampson d8e167637e Prototype support for named (pseudo-field) queries
As discussed here:
https://github.com/beetbox/beets/pull/3145#pullrequestreview-204523870

This would replace the need for #3149.
2019-02-17 13:41:05 -05:00
Jan Holthuis 5b68d88346 test: Add more playlist tests for the different relative_to settings 2019-02-17 19:36:26 +01:00