Commit c50eba65 authored by Laurent Bachelier's avatar Laurent Bachelier

Server: use __call__ method

parent 54125296
Pipeline #1 failed with stages
......@@ -451,9 +451,9 @@ class Server(object):
self.default_env['ASSNET_ROOT'] = root
def bind(self, hostname, port):
httpserver.serve(self.process, host=hostname, port=str(port))
httpserver.serve(self, host=hostname, port=str(port))
def process(self, environ, start_response):
def __call__(self, environ, start_response):
"""
WSGI interface
"""
......
......@@ -24,4 +24,4 @@ from wsgiref.handlers import CGIHandler
from assnet.server import Server
server = Server()
CGIHandler().run(server.process)
CGIHandler().run(server)
......@@ -24,4 +24,4 @@ from flup.server.fcgi import WSGIServer
from assnet.server import Server
server = Server()
WSGIServer(server.process).run()
WSGIServer(server).run()
......@@ -24,4 +24,4 @@ from assnet.server import Server
import os
server = Server()
application = server.process
application = server
......@@ -16,7 +16,7 @@ class ApiTest(TestCase):
self.root = mkdtemp(prefix='assnet_test_root')
Storage.create(self.root)
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
with open(os.path.join(self.root, 'penguins_are_cute'), 'w') as f:
f.write('HELLO')
......
......@@ -14,7 +14,7 @@ class AssetsTest(TestCase):
self.root = mkdtemp(prefix='assnet_test_root')
Storage.create(self.root)
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
datapath = os.path.join(self.root, 'test_data')
os.mkdir(datapath)
os.mkdir(os.path.join(datapath, 'assets'))
......
......@@ -14,7 +14,7 @@ class BaseWebTest(TestCase):
self.root = mkdtemp(prefix='assnet_test_root')
Storage.create(self.root)
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
def tearDown(self):
if self.root:
......
......@@ -17,7 +17,7 @@ class BuildURLTest(TestCase):
self.root = mkdtemp(prefix='assnet_test_root')
self.storage = Storage.create(self.root)
server = Server(self.root)
app = TestApp(server.process)
app = TestApp(server)
# fill root_url
app.get('http://penguin:42/')
self.root_url = build_root_url(self.storage)
......
......@@ -15,7 +15,7 @@ class EventTest(TestCase):
self.root = mkdtemp(prefix='assnet_test_root')
storage = Storage.create(self.root)
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
user = User(storage, 'penguin')
user.realname = 'Penguin'
......
......@@ -16,7 +16,7 @@ class GalleryTest(TestCase):
self.root = mkdtemp(prefix='assnet_test_root')
self.storage = Storage.create(self.root)
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
os.mkdir(os.path.join(self.root, 'images'))
os.mkdir(os.path.join(self.root, 'images', 'nothing'))
......
......@@ -22,7 +22,7 @@ class LoginTest(TestCase):
user.realname = 'Platypus'
user.save()
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
def tearDown(self):
if self.root:
......
......@@ -26,7 +26,7 @@ class RootDirTest(TestCase):
def test_notWorkingDir(self):
server = Server(self.root)
app = TestApp(server.process)
app = TestApp(server)
res = app.get("/", status=500)
assert "not an assnet working directory" in res.body
res = app.get("/penguin", status=500)
......@@ -36,7 +36,7 @@ class RootDirTest(TestCase):
def test_noRootPath(self):
server = Server(None)
app = TestApp(server.process)
app = TestApp(server)
res = app.get("/", status=500)
assert "No root path was provided" in res.body
res = app.get("/penguin", status=500)
......@@ -46,7 +46,7 @@ class RootDirTest(TestCase):
def test_configByEnv(self):
server = Server(None)
app = TestApp(server.process)
app = TestApp(server)
res = app.get("/", status=500, extra_environ={'ASSNET_ROOT': self.root})
assert "not an assnet working directory" in res.body
Storage.create(self.root)
......@@ -60,7 +60,7 @@ class RootDirTest(TestCase):
res = app.get("/penguin", status=404, extra_environ={'ASSNET_ROOT': self.a_wd})
server = Server(self.a_wd)
app = TestApp(server.process)
app = TestApp(server)
res = app.get("/", status=200)
res = app.get("/", status=200, extra_environ={'ASSNET_ROOT': self.root})
assert "penguin" in res.body
......
......@@ -26,7 +26,7 @@ class WebPermsTest(TestCase):
groupscfg['admin'] = group
groupscfg.save()
server = Server(self.root)
self.app = TestApp(server.process)
self.app = TestApp(server)
def tearDown(self):
if self.root:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment