mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
Add more steps
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
from behave.runner import Context
|
||||
|
||||
import httpx
|
||||
from behave import given
|
||||
from behave import when
|
||||
from behave import then
|
||||
|
||||
|
||||
BASE_URL = "http://localhost:8080"
|
||||
|
||||
|
||||
class PkiProject:
|
||||
def __init__(self, id: str):
|
||||
self.id = id
|
||||
@@ -25,11 +21,21 @@ def step_impl(context: Context, project_var: str):
|
||||
|
||||
@when('I send a {method} request to "{url}"')
|
||||
def step_impl(context: Context, method: str, url: str):
|
||||
with httpx.Client(base_url=BASE_URL) as client:
|
||||
context.response = client.request(method, url.format(**context.vars))
|
||||
context.response = context.http_client.request(method, url.format(**context.vars))
|
||||
|
||||
|
||||
@then('the response status code should be "{expected_status_code}"')
|
||||
def step_impl(context: Context, expected_status_code: int):
|
||||
assert context.response.status_code == expected_status_code, (
|
||||
f"{context.response.status_code} != {expected_status_code}"
|
||||
)
|
||||
|
||||
|
||||
@then('the response header "{header}" should contains non-empty value')
|
||||
def step_impl(context: Context, header: str):
|
||||
header_value = context.response.headers.get(header)
|
||||
assert header_value
|
||||
print(context.response.headers)
|
||||
assert header_value is not None, f"Header {header} not found in response"
|
||||
assert header_value, (
|
||||
f"Header {header} found in response, but value {header_value:!r} is empty"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user