steps.api.given =============== .. py:module:: steps.api.given Functions --------- .. autoapisummary:: steps.api.given.set_header_key steps.api.given.get_table steps.api.given.set_body steps.api.given.set_param_key steps.api.given.set_request_params steps.api.given.save_request steps.api.given.prepare_request steps.api.given.send_complete_request steps.api.given.send_request_with_path_parameter steps.api.given.resend_request steps.api.given.resend_request_setting_header steps.api.given.update_ref_request_header steps.api.given.resend_request_setting_body steps.api.given.resend_request_with_path_parameter steps.api.given.send_request steps.api.given.save_random_uuid steps.api.given.save_variable steps.api.given.save_data_in_response steps.api.given.add_test_section_description Module Contents --------------- .. py:function:: set_header_key(context: steps.api.utils.Context, key: str, method: str) -> None 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. :param context: The Behave context :param key: Header key to set :param method: Method to get the value (variable name or literal) :raises RuntimeWarning: If the value cannot be set using the method .. py:function:: get_table(context: steps.api.utils.Context) -> dict 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. :param context: The Behave context containing the table :return: Dictionary with keys and values from the table .. py:function:: set_body(context: steps.api.utils.Context) -> None Set the request body from a Gherkin table. Updates the request body with key-value pairs from the table. :param context: The Behave context containing the table .. py:function:: set_param_key(context: steps.api.utils.Context, key: str, value) Set a query parameter for the request. Processes the value to handle variable references and nested values. :param context: The Behave context :param key: Parameter key to set :param value: Parameter value (raw or variable reference) .. py:function:: set_request_params(context: steps.api.utils.Context) -> None Set request query parameters from a Gherkin table. Processes each row in the table to set request parameters. :param context: The Behave context containing the table .. py:function:: save_request(context: steps.api.utils.Context) Save the current request as a reference for later use. :param context: The Behave context .. py:function:: prepare_request(context: steps.api.utils.Context, api_type: str) Prepare a new request for a specific API type. :param context: The Behave context :param api_type: Type of API to prepare the request for :raises AssertionError: If the API type is not available in context.apis .. py:function:: send_complete_request(context: steps.api.utils.Context) 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. :param context: The Behave context :raises AssertionError: If connection errors occur .. py:function:: send_request_with_path_parameter(context, request_verb: str, current_path: str, path_key: str, method: str, log_response: bool = True) -> None 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. :param context: The Behave context :param request_verb: HTTP method (GET, POST, etc.) :param current_path: URL path template :param path_key: Key name in the path to replace with value :param method: Method to obtain the value for the path parameter :param log_response: Whether to log the response (default: True) .. py:function:: resend_request(context: steps.api.utils.Context, log_response: bool = True) -> None .. py:function:: resend_request_setting_header(context: steps.api.utils.Context, key: str, method: str, log_response: bool = True) -> None .. py:function:: update_ref_request_header(context: steps.api.utils.Context, key: str, method: str, log_response: bool = True) -> None .. py:function:: resend_request_setting_body(context: steps.api.utils.Context, log_response: bool = True) -> None .. py:function:: resend_request_with_path_parameter(context, path_key: str, method: str, log_response: bool = True) -> None .. py:function:: send_request(context: steps.api.utils.Context, request_verb: str, current_path: str, log_response: bool = True) -> None Make a request to a specific endpoint. Configures and sends a request to the specified path. :param context: The Behave context :param request_verb: HTTP method (GET, POST, etc.) :param current_path: URL path :param log_response: Whether to log the response (default: True) .. py:function:: save_random_uuid(context: steps.api.utils.Context, method: str) -> None .. py:function:: save_variable(context: steps.api.utils.Context, variable_key: str, method: str) -> None .. py:function:: save_data_in_response(context: steps.api.utils.Context, variable_key: str, method: str) -> None Save a field from the response to a variable. Extracts a field from the response JSON and saves it using the specified method. :param context: The Behave context :param variable_key: Key in the response to extract :param method: Method to save the value (variable specification) .. py:function:: add_test_section_description(context: steps.api.utils.Context, test_section_description: str)