From eedb963cf7df614b4f811da4a661e982d89e63bd Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Fri, 21 Nov 2014 14:45:46 -0200 Subject: refactoring so the app_test_client knows how to start itself in a thread --- service/test/support/integration/app_test_client.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'service/test/support/integration/app_test_client.py') diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index f6a95422..dea59399 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -14,7 +14,9 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import json +import multiprocessing import shutil +import time from klein.test_resource import requestMock, _render from leap.mail.imap.account import SoledadBackedAccount @@ -87,6 +89,13 @@ class AppTestClient: d.addCallback(get_request_written_data) return d, request + def run_on_a_thread(self, logfile='/tmp/app_test_client.log', port=4567, host='localhost'): + worker = lambda: self.app.run(host=host, port=port, logFile=open(logfile, 'w')) + process = multiprocessing.Process(target=worker) + process.start() + time.sleep(1) # just let it start + return lambda: process.terminate() + def get(self, path, get_args, as_json=True): request = requestMock(path) request.args = get_args -- cgit v1.2.3