diff --git a/tests/http/test_server.py b/tests/http/test_server.py index a3ef4997..79fb6866 100644 --- a/tests/http/test_server.py +++ b/tests/http/test_server.py @@ -12,8 +12,8 @@ from mopidy.http import actor, handlers class HttpServerTest(tornado.testing.AsyncHTTPTestCase): - def get_app(self): - config = { + def get_config(self): + return { 'http': { 'hostname': '127.0.0.1', 'port': 6680, @@ -21,6 +21,8 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): 'zeroconf': '', } } + + def get_app(self): core = mock.Mock() core.get_version = mock.MagicMock(name='get_version') core.get_version.return_value = mopidy.__version__ @@ -28,7 +30,7 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): apps = [dict(name='testapp')] statics = [dict(name='teststatic')] - http_frontend = actor.HttpFrontend(config=config, core=core) + http_frontend = actor.HttpFrontend(config=self.get_config(), core=core) http_frontend.apps = [{ 'name': 'mopidy', 'factory': handlers.make_mopidy_app_factory(apps, statics), @@ -57,6 +59,28 @@ class RootAppTest(HttpServerTest): self.assertEqual(response.headers['Cache-Control'], 'no-cache') +class LegacyStaticDirAppTest(HttpServerTest): + def get_config(self): + config = super(LegacyStaticDirAppTest, self).get_config() + config['http']['static_dir'] = os.path.dirname(__file__) + return config + + def test_should_return_index(self): + response = self.fetch('/', method='GET', follow_redirects=False) + + self.assertEqual(response.code, 404, 'No index.html in this dir') + + def test_should_return_static_files(self): + response = self.fetch('/test_server.py', method='GET') + + self.assertIn( + 'test_should_return_static_files', + tornado.escape.to_unicode(response.body)) + self.assertEqual( + response.headers['X-Mopidy-Version'], mopidy.__version__) + self.assertEqual(response.headers['Cache-Control'], 'no-cache') + + class MopidyAppTest(HttpServerTest): def test_should_return_index(self): response = self.fetch('/mopidy/', method='GET')