WIP: data handler success.feature
This commit is contained in:
committed by
Roberto Abdelkader Martínez Pérez
parent
513f12e2e4
commit
990cc1ba8f
@@ -1,7 +1,6 @@
|
|||||||
Feature: Fail to retrieve invalid resources from a handler in Kapow! server.
|
Feature: Fail to retrieve an invalid resource for a handler in Kapow! server.
|
||||||
If trying to access an invalid resource from
|
If trying to access an invalid resource for a handler
|
||||||
a handler then the server responds with an
|
then the server responds with an error.
|
||||||
error.
|
|
||||||
|
|
||||||
Scenario: Try to get an inexistent resource from a handler.
|
Scenario: Try to get an inexistent resource from a handler.
|
||||||
A request to retrieve an invalid resource
|
A request to retrieve an invalid resource
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Feature: Fail to retrieve resources from a nonexistent handler in Kapow! server.
|
Feature: Fail to retrieve resources from nonexistent handler in Kapow! server.
|
||||||
If trying to access a nonexistent handler then
|
If trying to access a nonexistent handler then the
|
||||||
the server responds with a not found error.
|
server responds with a noptfound error.
|
||||||
|
|
||||||
Scenario: Try to get a valid resource path from a nonexistent handler.
|
Scenario: Try to get a valid resource path from a nonexistent handler.
|
||||||
A request to retrieve a resource from a
|
A request to retrieve a resource from a
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
import shlex
|
import shlex
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -124,6 +126,7 @@ def step_impl(context, id):
|
|||||||
context.response = requests.delete(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
|
context.response = requests.delete(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
|
||||||
|
|
||||||
|
|
||||||
|
@given('I insert the route')
|
||||||
@when('I insert the route')
|
@when('I insert the route')
|
||||||
def step_impl(context):
|
def step_impl(context):
|
||||||
context.response = requests.put(f"{Env.KAPOW_CONTROLAPI_URL}/routes",
|
context.response = requests.put(f"{Env.KAPOW_CONTROLAPI_URL}/routes",
|
||||||
@@ -165,3 +168,23 @@ def step_impl(context, order):
|
|||||||
routes = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes")
|
routes = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes")
|
||||||
id = routes.json()[idx]["id"]
|
id = routes.json()[idx]["id"]
|
||||||
context.response = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
|
context.response = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
|
||||||
|
|
||||||
|
|
||||||
|
@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}")
|
||||||
|
context.background_request = threading.Thread(target=_back)
|
||||||
|
context.background_request.start()
|
||||||
|
|
||||||
|
|
||||||
|
@when('I get the resource {resource} for the current request handler')
|
||||||
|
def step_imp(context, resource):
|
||||||
|
def retrieve_request_id():
|
||||||
|
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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user