finished draf implementation of data debug
This commit is contained in:
committed by
Roberto Abdelkader Martínez Pérez
parent
990cc1ba8f
commit
b039db214f
@@ -2,6 +2,7 @@ from contextlib import suppress
|
||||
from time import sleep
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
import threading
|
||||
import shlex
|
||||
import socket
|
||||
@@ -170,21 +171,38 @@ def step_impl(context, order):
|
||||
context.response = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
|
||||
|
||||
|
||||
@when('I send a background request to the route {route}')
|
||||
@when('I send a background request to the route "{route}"')
|
||||
def step_imp(context, route):
|
||||
def _back():
|
||||
return requests.get(f"{Env.KAPOW_DATAAPI_URL}/{route}")
|
||||
resource_route = f"{Env.KAPOW_DATAAPI_URL}/{route}"
|
||||
return requests.get(resource_route)
|
||||
context.background_request = threading.Thread(target=_back)
|
||||
context.background_request.start()
|
||||
|
||||
|
||||
@when('I get the resource {resource} for the current request handler')
|
||||
@when('I get the resource "{resource}" for the current request handler')
|
||||
def step_imp(context, resource):
|
||||
def retrieve_request_id():
|
||||
requests_dir = os.path.exists('/tmp/wip')
|
||||
while not requests_dir:
|
||||
time.sleep(1)
|
||||
requests_dir = os.path.exists('/tmp/wip')
|
||||
target_count = len(os.listdir('/tmp/wip'))
|
||||
while target_count <= 0:
|
||||
time.sleep(1)
|
||||
target_count = len(os.listdir('/tmp/wip'))
|
||||
target = os.listdir('/tmp/wip')[0]
|
||||
with open(target, "r") as f:
|
||||
return f.readline().strip()
|
||||
background_request_id = retrieve_request_id()
|
||||
resource = f"/handlers/{background_request_id}/{resource}"
|
||||
context.response = requests.get(resource)
|
||||
|
||||
with open(os.path.join("/tmp/wip", target), "r") as f:
|
||||
return f.readline().strip()
|
||||
def remove_request_id(request_id):
|
||||
os.remove(os.path.join("/tmp/wip", request_id))
|
||||
background_request_id = retrieve_request_id()
|
||||
resource = f"{Env.KAPOW_CONTROLAPI_URL}/handlers/{background_request_id}/{resource}"
|
||||
context.response = requests.get(resource)
|
||||
remove_request_id(background_request_id)
|
||||
|
||||
|
||||
@then('I get the following raw body')
|
||||
def step_impl(context):
|
||||
assert is_subset(context.text.strip(), context.response.text.strip())
|
||||
|
||||
Reference in New Issue
Block a user