Made some tweaks to the default engine.py

This commit is contained in:
Colm O'Connor 2015-08-01 18:00:50 +08:00
parent 5a22dae175
commit 620364aebd

View File

@ -1,9 +1,9 @@
from hitchserve import ServiceBundle
from os import path
from subprocess import call, PIPE from subprocess import call, PIPE
from os import path
import hitchpostgres import hitchpostgres
import hitchselenium import hitchselenium
import hitchpython import hitchpython
import hitchserve
import hitchredis import hitchredis
import hitchtest import hitchtest
import hitchsmtp import hitchsmtp
@ -39,7 +39,7 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
redis_package.build() redis_package.build()
redis_package.verify() redis_package.verify()
self.services = ServiceBundle( self.services = hitchserve.ServiceBundle(
project_directory=PROJECT_DIRECTORY, project_directory=PROJECT_DIRECTORY,
startup_timeout=float(self.settings["startup_timeout"]), startup_timeout=float(self.settings["startup_timeout"]),
shutdown_timeout=5.0, shutdown_timeout=5.0,
@ -132,7 +132,7 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
"""Wait for, and return email.""" """Wait for, and return email."""
self.services['HitchSMTP'].logs.out.tail.until_json( self.services['HitchSMTP'].logs.out.tail.until_json(
lambda email: containing in email['payload'] or containing in email['subject'], lambda email: containing in email['payload'] or containing in email['subject'],
timeout=15, timeout=25,
lines_back=1, lines_back=1,
) )
@ -143,19 +143,15 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
def on_failure(self): def on_failure(self):
"""Stop and IPython.""" """Stop and IPython."""
if not self.settings['quiet']: if not self.settings['quiet']:
if call(["which", "kaching"], stdout=PIPE, stderr=PIPE) == 0:
call(["kaching", "fail"]) # sudo pip install kaching for sad sound
if self.settings.get("pause_on_failure", False): if self.settings.get("pause_on_failure", False):
self.pause(message=self.stacktrace.to_template()) self.pause(message=self.stacktrace.to_template())
def on_success(self): def on_success(self):
"""Ka-ching!""" """Pause on success if enabled."""
if not self.settings['quiet'] and call(["which", "kaching"], stdout=PIPE, stderr=PIPE) == 0:
call(["kaching", "pass"]) # sudo pip install kaching for happy sound
if self.settings.get("pause_on_success", False): if self.settings.get("pause_on_success", False):
self.pause(message="SUCCESS") self.pause(message="SUCCESS")
def tear_down(self): def tear_down(self):
"""Commit genocide on the services required to run your test.""" """Shut down services required to run your test."""
if hasattr(self, 'services'): if hasattr(self, 'services'):
self.services.shutdown() self.services.shutdown()