Factorized run_kapow_server function to allow reuse.

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-08-21 09:11:10 +02:00
parent 126beca86e
commit 7d83432500
+7 -11
View File
@@ -46,10 +46,7 @@ if Env.KAPOW_DEBUG_TESTS:
requests_log.setLevel(logging.DEBUG) requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True requests_log.propagate = True
def run_kapow_server(context):
@given('I have a just started Kapow! server')
@given('I have a running Kapow! server')
def step_impl(context):
context.server = subprocess.Popen( context.server = subprocess.Popen(
shlex.split(Env.KAPOW_SERVER_CMD), shlex.split(Env.KAPOW_SERVER_CMD),
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
@@ -71,6 +68,11 @@ def step_impl(context):
assert open_ports, "API is unreachable after KAPOW_BOOT_TIMEOUT" assert open_ports, "API is unreachable after KAPOW_BOOT_TIMEOUT"
@given('I have a just started Kapow! server')
@given('I have a running Kapow! server')
def step_impl(context):
run_kapow_server(context)
@when('I request a routes listing') @when('I request a routes listing')
def step_impl(context): def step_impl(context):
@@ -85,13 +87,7 @@ def step_impl(context):
@given('I have a Kapow! server whith the following routes') @given('I have a Kapow! server whith the following routes')
def step_impl(context): def step_impl(context):
context.server = subprocess.Popen( run_kapow_server(context)
Env.KAPOW_SERVER_CMD,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
shell=True)
is_running = context.server.poll() is None
assert is_running, "Server is not running!"
if not hasattr(context, 'table'): if not hasattr(context, 'table'):
raise RuntimeError("A table must be set for this step.") raise RuntimeError("A table must be set for this step.")