summaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-08-06 13:27:10 -0300
committerBruno Wagner <bwgpro@gmail.com>2015-08-12 17:17:17 -0300
commit3aa60047aae17ac6945fa85cb76fa1c8cfae046c (patch)
tree5b9678c01736773e06c27448e6f7856c444c3dca /common/src
parent242e21dff3260a2dba303299e41667679e6d2e87 (diff)
[tests] Twisted WSGI is optional
Some tests still rely on python WSGI logic while others expect HTTP/1.1 from Twisted WSGI. While we can't use a single implementation for all, both are needed. startServer -> python default wsgi (http 1.0) startTwistedServer -> Twisted WSGI (http 1.1 'production-like')
Diffstat (limited to 'common/src')
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/__init__.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/__init__.py b/common/src/leap/soledad/common/tests/u1db_tests/__init__.py
index 132c45e3..c34f5ef1 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/__init__.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/__init__.py
@@ -356,7 +356,7 @@ class TestCaseWithServer(TestCase):
def url_scheme(self):
return 'http'
- def startServer(self):
+ def startTwistedServer(self):
application = self.make_app()
resource = WSGIResource(reactor, reactor.getThreadPool(), application)
site = Site(resource)
@@ -365,6 +365,18 @@ class TestCaseWithServer(TestCase):
self.server_address = (host.host, host.port)
self.addCleanup(self.port.stopListening)
+ def startServer(self):
+ server_def = self.server_def()
+ server_class, shutdown_meth, _ = server_def
+ application = self.make_app()
+ self.server = server_class(('127.0.0.1', 0), application)
+ self.server_thread = threading.Thread(target=self.server.serve_forever,
+ kwargs=dict(poll_interval=0.01))
+ self.server_thread.start()
+ self.addCleanup(self.server_thread.join)
+ self.addCleanup(getattr(self.server, shutdown_meth))
+ self.server_address = self.server.server_address
+
def getURL(self, path=None):
host, port = self.server_address
if path is None: