From 5dd256d5d5295dd889a4bf652561e0523e70aed9 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Wed, 29 Jul 2015 11:03:18 +0200 Subject: Fixed all functional tests using crochet. - Issue #420 - Added crochet as a test dependency - crochet now executes twisted in same process, in a background thread --- service/test/functional/features/environment.py | 12 ++++++++++-- service/test/support/integration/app_test_client.py | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'service/test') diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index 437529b8..4967a356 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -16,6 +16,9 @@ import logging import uuid +from crochet import setup, wait_for +setup() + from test.support.dispatcher.proxy import Proxy from test.support.integration import AppTestClient from selenium import webdriver @@ -23,18 +26,23 @@ from selenium import webdriver from pixelated.resources.features_resource import FeaturesResource +@wait_for(timeout=5.0) +def start_app_test_client(client): + return client.start_client() + + def before_all(context): logging.disable('INFO') client = AppTestClient() + start_app_test_client(client) + client.listenTCP() proxy = Proxy(proxy_port='8889', app_port='4567') FeaturesResource.DISABLED_FEATURES.append('autoRefresh') context.client = client context.call_to_terminate_proxy = proxy.run_on_a_thread() - context.call_to_terminate = client.run_on_a_thread(logfile='/tmp/behave-tests.log') def after_all(context): - context.call_to_terminate() context.call_to_terminate_proxy() diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index db85f931..c6cd9936 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -103,9 +103,12 @@ class AppTestClient(object): d.addCallback(get_request_written_data) return d, request + def listenTCP(self, port=4567, host='0.0.0.0'): + reactor.listenTCP(port, Site(self.resource), interface=host) + def run_on_a_thread(self, logfile='/tmp/app_test_client.log', port=4567, host='0.0.0.0'): def _start(): - reactor.listenTCP(port, Site(self.resource), interface=host) + self.listenTCP(port, host) reactor.run() process = multiprocessing.Process(target=_start) process.start() -- cgit v1.2.3