mopidy/tests/mpd/protocol
Thomas Adamcik 455f3dd403 mpd: Write commands helper for tokenized command handling
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)
2014-01-19 19:59:07 +01:00
..
__init__.py dummy: Move dummy backend back into the mopidy package 2014-01-18 01:38:10 +01:00
test_audio_output.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_authentication.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_channels.py mpd: Annotate exceptions with current command automatically (fixes #649) 2014-01-18 00:34:41 +01:00
test_command_list.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_commands_decorator.py mpd: Write commands helper for tokenized command handling 2014-01-19 19:59:07 +01:00
test_connection.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_current_playlist.py Merge pull request #647 from adamcik/feature/browse-by-uri 2014-01-17 15:58:39 -08:00
test_idle.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_music_db.py mpd: Switch mpd to use path<->uri mapping for browsing 2014-01-17 17:16:24 +01:00
test_playback.py mpd: Annotate exceptions with current command automatically (fixes #649) 2014-01-18 00:34:41 +01:00
test_reflection.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_regression.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00
test_status.py mpd: Annotate exceptions with current command automatically (fixes #649) 2014-01-18 00:34:41 +01:00
test_stickers.py mpd: Annotate exceptions with current command automatically (fixes #649) 2014-01-18 00:34:41 +01:00
test_stored_playlists.py mpd: Annotate exceptions with current command automatically (fixes #649) 2014-01-18 00:34:41 +01:00
test_tokenizer.py mpd: Add MPD tokenizer 2014-01-19 13:47:09 +01:00