From 720a403439b9d1086ceafedb1bab136f1f02d4e8 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 4 Jun 2014 21:32:54 +0200 Subject: [PATCH] http: Remove unused Router class --- docs/api/http-server.rst | 7 ------ mopidy/http/__init__.py | 45 --------------------------------------- tests/http/test_router.py | 44 -------------------------------------- 3 files changed, 96 deletions(-) delete mode 100644 tests/http/test_router.py diff --git a/docs/api/http-server.rst b/docs/api/http-server.rst index af401a24..45c8df58 100644 --- a/docs/api/http-server.rst +++ b/docs/api/http-server.rst @@ -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: diff --git a/mopidy/http/__init__.py b/mopidy/http/__init__.py index 7718c2b6..2e131817 100644 --- a/mopidy/http/__init__.py +++ b/mopidy/http/__init__.py @@ -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 diff --git a/tests/http/test_router.py b/tests/http/test_router.py deleted file mode 100644 index 6930b51d..00000000 --- a/tests/http/test_router.py +++ /dev/null @@ -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()