<s> from __future__ import absolute_import , unicode_literals <EOL> import unittest <EOL> import pykka <EOL> from mopidy import core <EOL> from mopidy . internal import deprecation <EOL> from mopidy . mpd . dispatcher import MpdDispatcher <EOL> from mopidy . mpd . exceptions import MpdAckError <EOL> from tests import dummy_backend <EOL> class MpdDispatcherTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> config = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:password>' : None , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> self . backend = dummy_backend . create_proxy ( ) <EOL> self . dispatcher = MpdDispatcher ( config = config ) <EOL> with deprecation . ignore ( ) : <EOL> self . core = core . Core . start ( backends = [ self . backend ] ) . proxy ( ) <EOL> def tearDown ( self ) : <EOL> pykka . ActorRegistry . stop_all ( ) <EOL> def test_call_handler_for_unknown_command_raises_exception ( self ) : <EOL> with self . assertRaises ( MpdAckError ) as cm : <EOL> self . dispatcher . _call_handler ( '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> cm . exception . get_mpd_ack ( ) , <EOL> '<STR_LIT>' ) <EOL> def test_handling_unknown_request_yields_error ( self ) : <EOL> result = self . dispatcher . handle_request ( '<STR_LIT>' ) <EOL> self . assertEqual ( result [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> def test_handling_blacklisted_command ( self ) : <EOL> result = self . dispatcher . handle_request ( '<STR_LIT>' ) <EOL> self . assertEqual ( result [ <NUM_LIT:0> ] , '<STR_LIT>' <EOL> '<STR_LIT>' ) </s>
