summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-11-21 14:45:46 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-11-21 15:10:42 -0200
commiteedb963cf7df614b4f811da4a661e982d89e63bd (patch)
treee507cad5f45b865f2a16e27d3d424ea54d6e0608 /service
parentd8c8de12b1119b6d955a4a28e7b066390da6b2a3 (diff)
refactoring so the app_test_client knows how to start itself in a thread
Diffstat (limited to 'service')
-rw-r--r--service/test/functional/features/environment.py15
-rw-r--r--service/test/support/integration/app_test_client.py9
2 files changed, 14 insertions, 10 deletions
diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py
index 537cd969..4c9af63e 100644
--- a/service/test/functional/features/environment.py
+++ b/service/test/functional/features/environment.py
@@ -18,25 +18,20 @@ import multiprocessing
import logging
from test.support.integration import AppTestClient
from selenium import webdriver
+from pixelated.controllers.features_controller import FeaturesController
import pixelated
def before_all(context):
- pixelated.controllers.features_controller.FeaturesController.DISABLED_FEATURES.append('autoRefresh')
+ logging.disable('INFO')
client = AppTestClient()
+ FeaturesController.DISABLED_FEATURES.append('autoRefresh')
context.client = client
- logging.disable('INFO')
-
- worker = lambda: client.app.run(host='localhost', port=4567, logFile=open('/tmp/behave-tests.log', 'w'))
- context._process = multiprocessing.Process(target=worker)
- context._process.start()
-
- # we must wait the server start listening
- time.sleep(1)
+ context.call_to_terminate = client.run_on_a_thread(logfile='/tmp/behave-tests.log')
def after_all(context):
- context._process.terminate()
+ context.call_to_terminate()
def before_feature(context, feature):
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