Skip to content

Commit

Permalink
Update the unit tests
Browse files Browse the repository at this point in the history
* Fix the import error
* Improve the code style
  • Loading branch information
qiuzhong committed Nov 12, 2018
1 parent a3078b3 commit f4bd28a
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions tools/wptserve/tests/functional/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
from six.moves.urllib.error import HTTPError

wptserve = pytest.importorskip("wptserve")
from .base import TestUsingServer, TestUsingH2Server, \
TestWrapperHandlerUsingServer, doc_root
from .base import TestUsingServer, TestUsingH2Server, doc_root
from .base import TestWrapperHandlerUsingServer

from serve.serve import WorkersHandler, WindowHandler, AnyHtmlHandler,\
SharedWorkersHandler, ServiceWorkersHandler, AnyWorkerHandler
from serve import serve

class TestFileHandler(TestUsingServer):
def test_GET(self):
Expand Down Expand Up @@ -392,62 +391,56 @@ def test_requesting_multiple_resources(self):


class TestWorkersHandler(TestWrapperHandlerUsingServer):

dummy_js_files = {'foo.worker.js': '',
'foo.any.js': ''}

def test_any_worker_html(self):
self.run_wrapper_test('foo.any.worker.html',
'text/html', WorkersHandler)
'text/html', serve.WorkersHandler)

def test_worker_html(self):
self.run_wrapper_test('foo.worker.html',
'text/html', WorkersHandler)
'text/html', serve.WorkersHandler)


class TestWindowHandler(TestWrapperHandlerUsingServer):

dummy_js_files = {'foo.window.js': ''}

def test_window_html(self):
self.run_wrapper_test('foo.window.html',
'text/html', WindowHandler)
'text/html', serve.WindowHandler)


class TestAnyHtmlHandler(TestWrapperHandlerUsingServer):

dummy_js_files = {'foo.any.js': ''}

def test_any_html(self):
self.run_wrapper_test('foo.any.html',
'text/html', AnyHtmlHandler)
'text/html', serve.AnyHtmlHandler)


class TestSharedWorkersHandler(TestWrapperHandlerUsingServer):

dummy_js_files = {'foo.any.js': '// META: global=sharedworker\n'}

def test_any_sharedworkers_html(self):
self.run_wrapper_test('foo.any.sharedworker.html',
'text/html', SharedWorkersHandler)
'text/html', serve.SharedWorkersHandler)


class TestServiceWorkersHandler(TestWrapperHandlerUsingServer):

dummy_js_files = {'foo.any.js': '// META: global=serviceworker\n'}

def test_serviceworker_html(self):
self.run_wrapper_test('foo.any.serviceworker.html',
'text/html', ServiceWorkersHandler)
'text/html', serve.ServiceWorkersHandler)


class TestAnyWorkerHandler(TestWrapperHandlerUsingServer):

dummy_js_files = {'bar.any.js': ''}

def test_any_work_js(self):
self.run_wrapper_test('bar.any.worker.js', 'text/javascript',
AnyWorkerHandler)
serve.AnyWorkerHandler)


if __name__ == '__main__':
Expand Down

0 comments on commit f4bd28a

Please sign in to comment.