steps.api.given
Functions
|
Set a specific HTTP header for the request. |
|
Convert a Gherkin table to a Python dictionary. |
|
Set the request body from a Gherkin table. |
|
Set a query parameter for the request. |
|
Set request query parameters from a Gherkin table. |
|
Save the current request as a reference for later use. |
|
Prepare a new request for a specific API type. |
|
Send the prepared request and handle response and logging. |
|
Make a request with a path parameter to a specific endpoint. |
|
|
|
|
|
|
|
|
|
Make a request to a specific endpoint. |
|
|
|
|
|
Save a field from the response to a variable. |
|
Module Contents
- steps.api.given.set_header_key(context: steps.api.utils.Context, key: str, method: str) None[source]
Set a specific HTTP header for the request.
Attempts to read the value from a variable using the provided method, and adds special handling for Authorization headers.
- Parameters:
context – The Behave context
key – Header key to set
method – Method to get the value (variable name or literal)
- Raises:
RuntimeWarning – If the value cannot be set using the method
- steps.api.given.get_table(context: steps.api.utils.Context) dict[source]
Convert a Gherkin table to a Python dictionary.
Processes a Behave table with ‘key’ and ‘value’ columns, parsing nested values and variable references in the process.
- Parameters:
context – The Behave context containing the table
- Returns:
Dictionary with keys and values from the table
- steps.api.given.set_body(context: steps.api.utils.Context) None[source]
Set the request body from a Gherkin table.
Updates the request body with key-value pairs from the table.
- Parameters:
context – The Behave context containing the table
- steps.api.given.set_param_key(context: steps.api.utils.Context, key: str, value)[source]
Set a query parameter for the request.
Processes the value to handle variable references and nested values.
- Parameters:
context – The Behave context
key – Parameter key to set
value – Parameter value (raw or variable reference)
- steps.api.given.set_request_params(context: steps.api.utils.Context) None[source]
Set request query parameters from a Gherkin table.
Processes each row in the table to set request parameters.
- Parameters:
context – The Behave context containing the table
- steps.api.given.save_request(context: steps.api.utils.Context)[source]
Save the current request as a reference for later use.
- Parameters:
context – The Behave context
- steps.api.given.prepare_request(context: steps.api.utils.Context, api_type: str)[source]
Prepare a new request for a specific API type.
- Parameters:
context – The Behave context
api_type – Type of API to prepare the request for
- Raises:
AssertionError – If the API type is not available in context.apis
- steps.api.given.send_complete_request(context: steps.api.utils.Context)[source]
Send the prepared request and handle response and logging.
Sends the request, handles potential exceptions, and logs request and response details based on the context configuration.
- Parameters:
context – The Behave context
- Raises:
AssertionError – If connection errors occur
- steps.api.given.send_request_with_path_parameter(context, request_verb: str, current_path: str, path_key: str, method: str, log_response: bool = True) None[source]
Make a request with a path parameter to a specific endpoint.
Configures and sends a request with a path parameter replaced by the value obtained from the specified method.
- Parameters:
context – The Behave context
request_verb – HTTP method (GET, POST, etc.)
current_path – URL path template
path_key – Key name in the path to replace with value
method – Method to obtain the value for the path parameter
log_response – Whether to log the response (default: True)
- steps.api.given.resend_request(context: steps.api.utils.Context, log_response: bool = True) None[source]
- steps.api.given.resend_request_setting_header(context: steps.api.utils.Context, key: str, method: str, log_response: bool = True) None[source]
- steps.api.given.update_ref_request_header(context: steps.api.utils.Context, key: str, method: str, log_response: bool = True) None[source]
- steps.api.given.resend_request_setting_body(context: steps.api.utils.Context, log_response: bool = True) None[source]
- steps.api.given.resend_request_with_path_parameter(context, path_key: str, method: str, log_response: bool = True) None[source]
- steps.api.given.send_request(context: steps.api.utils.Context, request_verb: str, current_path: str, log_response: bool = True) None[source]
Make a request to a specific endpoint.
Configures and sends a request to the specified path.
- Parameters:
context – The Behave context
request_verb – HTTP method (GET, POST, etc.)
current_path – URL path
log_response – Whether to log the response (default: True)
- steps.api.given.save_random_uuid(context: steps.api.utils.Context, method: str) None[source]
- steps.api.given.save_variable(context: steps.api.utils.Context, variable_key: str, method: str) None[source]
- steps.api.given.save_data_in_response(context: steps.api.utils.Context, variable_key: str, method: str) None[source]
Save a field from the response to a variable.
Extracts a field from the response JSON and saves it using the specified method.
- Parameters:
context – The Behave context
variable_key – Key in the response to extract
method – Method to save the value (variable specification)
- steps.api.given.add_test_section_description(context: steps.api.utils.Context, test_section_description: str)[source]