http: Remove unused Router class

This commit is contained in:
Stein Magnus Jodal 2014-06-04 21:32:54 +02:00
parent 33228f2528
commit 720a403439
3 changed files with 0 additions and 96 deletions

View File

@ -187,10 +187,3 @@ http://localhost:6680/mywebclient/.
})
# See the Extension API for the full details on this class
HTTP Router API
===============
.. autoclass:: mopidy.http.Router
:members:

View File

@ -45,48 +45,3 @@ class Extension(ext.Extension):
'name': 'mopidy',
'factory': mopidy_app_factory,
})
class Router(object):
"""
HTTP router interface.
Extensions that wish to extend the HTTP server needs to subclass this class
and have :meth:`~mopidy.ext.Extension.setup` register the class in the
extension registry under the ``http:router`` key.
:param config: dict structure of the entire Mopidy configuration
:param core: :class:`pykka.ActorProxy` to the core actor, giving full
access to the core API
"""
name = None
"""Name of the HTTP router.
Must be overridden by all subclasses.
This should be the same as the :attr:`~mopidy.ext.Extension.ext_name` of
the Mopidy extension implementing an HTTP router. The :attr:`~Router.name`
will be used to namespace all URLs handled by this router.
For example, if :attr:`~Router.name` is ``soundspot``, then the router will
manage all requests starting with ``http://localhost:6680/soundspot``.
"""
def __init__(self, config, core):
self.config = config
self.core = core
if not self.name:
raise ValueError('Router name must be set')
def get_request_handlers(self):
"""
Get request handlers for the URL namespace owned by this router.
Must be overridden by all subclasses.
Returns a list of request handlers compatible with
:class:`tornado.web.Application`. The URL patterns should not include
the :attr:`name` prefix, as that will be prepended by the web server.
"""
raise NotImplementedError

View File

@ -1,44 +0,0 @@
from __future__ import unicode_literals
import unittest
import mock
from mopidy import http
class TestRouter(http.Router):
name = 'test'
class TestRouterMissingName(http.Router):
pass
class HttpRouterTest(unittest.TestCase):
def setUp(self):
self.config = {
'http': {
'hostname': '127.0.0.1',
'port': 6680,
'static_dir': None,
'zeroconf': '',
}
}
self.core = mock.Mock()
def test_keeps_reference_to_config_and_core(self):
router = TestRouter(self.config, self.core)
self.assertIs(router.config, self.config)
self.assertIs(router.core, self.core)
def test_undefined_name_raises_error(self):
with self.assertRaises(ValueError):
TestRouterMissingName(self.config, self.core)
def test_undefined_request_handlers_raises_error(self):
router = TestRouter(self.config, self.core)
with self.assertRaises(NotImplementedError):
router.get_request_handlers()