diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-11-21 14:45:46 -0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-11-21 15:10:42 -0200 |
commit | eedb963cf7df614b4f811da4a661e982d89e63bd (patch) | |
tree | e507cad5f45b865f2a16e27d3d424ea54d6e0608 /service/test/support | |
parent | d8c8de12b1119b6d955a4a28e7b066390da6b2a3 (diff) |
refactoring so the app_test_client knows how to start itself in a thread
Diffstat (limited to 'service/test/support')
-rw-r--r-- | service/test/support/integration/app_test_client.py | 9 |
1 files changed, 9 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. 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 |