mopidy/tests/mpd
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
..
protocol mpd: Write commands helper for tokenized command handling 2014-01-19 19:59:07 +01:00
__init__.py mpd: Move mopidy.{frontends => }.mpd 2013-12-31 14:11:16 +01:00
test_dispatcher.py dummy: Move dummy backend back into the mopidy package 2014-01-18 01:38:10 +01:00
test_exceptions.py mpd: Annotate exceptions with current command automatically (fixes #649) 2014-01-18 00:34:41 +01:00
test_status.py dummy: Move dummy backend back into the mopidy package 2014-01-18 01:38:10 +01:00
test_translator.py Rename test files to pattern expected by test runners 2014-01-15 00:01:50 +01:00