From 6c6600c37b2a61d652aeebe3ae0f6cfcde26e44d Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 21 Jun 2014 16:21:39 +0200 Subject: [PATCH] http: Group HTTP server tests --- tests/http/test_server.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/http/test_server.py b/tests/http/test_server.py index 25373812..1e645025 100644 --- a/tests/http/test_server.py +++ b/tests/http/test_server.py @@ -33,7 +33,9 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): return tornado.web.Application(http_frontend._get_request_handlers()) - def test_root_should_return_index(self): + +class RootAppTest(HttpServerTest): + def test_should_return_index(self): response = self.fetch('/', method='GET') self.assertIn( @@ -43,7 +45,9 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): response.headers['X-Mopidy-Version'], mopidy.__version__) self.assertEqual(response.headers['Cache-Control'], 'no-cache') - def test_mopidy_should_return_index(self): + +class MopidyAppTest(HttpServerTest): + def test_should_return_index(self): response = self.fetch('/mopidy/', method='GET') self.assertIn( @@ -53,7 +57,7 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): response.headers['X-Mopidy-Version'], mopidy.__version__) self.assertEqual(response.headers['Cache-Control'], 'no-cache') - def test_mopidy_should_return_index_no_slash(self): + def test_without_slash_should_return_index(self): response = self.fetch('/mopidy', method='GET') self.assertIn( @@ -63,7 +67,7 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): response.headers['X-Mopidy-Version'], mopidy.__version__) self.assertEqual(response.headers['Cache-Control'], 'no-cache') - def test_should_return_js(self): + def test_should_return_static_files(self): response = self.fetch('/mopidy/mopidy.js', method='GET') self.assertIn( @@ -73,6 +77,8 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): response.headers['X-Mopidy-Version'], mopidy.__version__) self.assertEqual(response.headers['Cache-Control'], 'no-cache') + +class MopidyWebSocketHandlerTest(HttpServerTest): def test_should_return_ws(self): response = self.fetch('/mopidy/ws', method='GET') @@ -87,6 +93,8 @@ class HttpServerTest(tornado.testing.AsyncHTTPTestCase): 'Can "Upgrade" only to "WebSocket".', tornado.escape.to_unicode(response.body)) + +class MopidyRPCHandlerTest(HttpServerTest): def test_should_return_rpc_error(self): cmd = tornado.escape.json_encode({'action': 'get_version'})