- Split into smaller test cases more or less per command
- Created a BasePopulatedTracklistTestCase with a sensible setUp
- Modified test cases to work with the common tracklist state
- Replaced all calls to tracklist.add(tracks=...) with uris=...
- Test tracklist ordering in more compact way that also gives better error
messages
...and not False, because the mute state is unknown (None) and not
unmuted (False) when there is no mixer.
Note that this change does not affect the MPD responses.
This was disabled together with a bunch of other changes without any
explanation in commit f24ca36e5a. I'm
guessing that this wasn't intentional, and no test covered the case.
Previously, test_list_album_with_artist_name would only test that the
command didn't fail. Now it also checks that the response is correct.
That is, that the response contains albums.
This makes the test detect the error reported in #817.
Replace the playlist uri/name mapping with a mapping for all the items
in browse. Check the mapping when browsing a path.
This has the added benefit of serving as a cache for browse, so we don't
need to traverse the path parts and lookup each of them for each call to
browse.
This provides a class which works as a command registry. Functions are added to
the registry through a method on the class `add`. Add acts as a decorator
taking in the name of the command and optionally type converters for arguments.
When handling requests, we can now tokenize the line, and then just pass the
arguments to our commands helper. It will lookup the correct handler and apply
any validation before calling the original function.
For the sake of testing the original function is not wrapped. This the
functions, and anything testing them directly can simply assume pre-converted
data as long as type annotations are in place.
A sample usage would be:
@protocol.commands.add('addid', position=protocol.integer)
def addid(context, uri, position=None)
pass
def handle_request(line):
tokens = protocol.tokenizer(line)
context = ...
result = protocol.commands.call(tokens, context=context)