steps.api.utils =============== .. py:module:: steps.api.utils Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/steps/api/utils/api/index /autoapi/steps/api/utils/context/index /autoapi/steps/api/utils/custom_exceptions/index /autoapi/steps/api/utils/parser/index /autoapi/steps/api/utils/request/index /autoapi/steps/api/utils/result_formatter/index Attributes ---------- .. autoapisummary:: steps.api.utils.POST steps.api.utils.GET steps.api.utils.PUT steps.api.utils.DELETE Classes ------- .. autoapisummary:: steps.api.utils.Api steps.api.utils.Request steps.api.utils.CloudContextHandler steps.api.utils.Context Functions --------- .. autoapisummary:: steps.api.utils.log_allure steps.api.utils.attach_swagger_link steps.api.utils.parse_nested_value steps.api.utils.try_read_from_variable steps.api.utils.try_save_value_to_variable steps.api.utils.check_expected_values_in_response Package Contents ---------------- .. py:class:: Api(api_type: str, url: str, swagger_file: str) .. py:attribute:: OPEN_API_PATCH_KEY :value: '#/components/schemas/DummySchema' .. py:attribute:: OPEN_API_DUMMY_SCHEMA .. py:attribute:: api_type .. py:attribute:: url .. py:attribute:: swagger_file .. py:attribute:: schemas :type: dict :value: None .. py:attribute:: openapi :value: None .. py:attribute:: requests_tested .. py:method:: load_swagger(patch_open_api: bool = False, logger=None) .. py:method:: get_schema_from_request(request: steps.api.utils.request.Request) .. py:method:: get_schema(url: str, method: str, status_code: int | str) .. py:method:: get_json_schema_exception(request) -> BaseException | None .. py:method:: get_invalid_data_exception(request, invalid_data) -> BaseException .. py:method:: get_request_tested_dict(request) .. py:method:: check_schema(request, exceptions: list[BaseException]) .. py:method:: check_extra(request, success: bool, description=None) .. py:method:: check_status(request, exception: steps.api.utils.custom_exceptions.AWrongStatus) .. py:method:: create_all_requests_tested() .. py:data:: POST :value: 'POST' .. py:data:: GET :value: 'GET' .. py:data:: PUT :value: 'PUT' .. py:data:: DELETE :value: 'DELETE' .. py:class:: Request(api=None, timeout: int = 3) Bases: :py:obj:`requests.Request` A user-created :class:`Request ` object. Used to prepare a :class:`PreparedRequest `, which is sent to the server. :param method: HTTP method to use. :param url: URL to send. :param headers: dictionary of headers to send. :param files: dictionary of {filename: fileobject} files to multipart upload. :param data: the body to attach to the request. If a dictionary or list of tuples ``[(key, value)]`` is provided, form-encoding will take place. :param json: json for the body to attach to the request (if files or data is not specified). :param params: URL parameters to append to the URL. If a dictionary or list of tuples ``[(key, value)]`` is provided, form-encoding will take place. :param auth: Auth handler or (user, pass) tuple. :param cookies: dictionary or CookieJar of cookies to attach to this request. :param hooks: dictionary of callback hooks, for internal usage. Usage:: >>> import requests >>> req = requests.Request('GET', 'https://httpbin.org/get') >>> req.prepare() .. py:attribute:: api :type: steps.api.utils.api.Api :value: None .. py:attribute:: method :value: '' .. py:attribute:: headers .. py:attribute:: params .. py:attribute:: body .. py:attribute:: original_path_url :value: '' .. py:attribute:: path_parameters .. py:attribute:: path_url :value: '' .. py:attribute:: url :value: '' .. py:attribute:: log :value: True .. py:attribute:: timeout :value: 3 .. py:attribute:: expected_status_code :value: '200' .. py:attribute:: response :value: None .. py:method:: set_header(key, value) .. py:method:: set_body(key, value) .. py:method:: set_param(key, value) .. py:method:: set_authorization_header(value) .. py:method:: set_json_content_type() .. py:method:: set_form_content_type() .. py:method:: set_url(path_url: str, path_parameters: dict = {}) .. py:method:: set_method(method: str) .. py:method:: send() .. py:method:: get_pretty_request() -> str .. py:method:: get_pretty_response() -> str .. py:method:: copy() .. py:class:: CloudContextHandler(context: behave.runner.Context) .. py:attribute:: context .. py:method:: configure_logger(output_dir: str = '') .. py:method:: initialize(config: dict, output_dir: str, api_file: str, users_file: str) .. py:method:: load_config(config: dict) .. py:method:: load_apis(api_file) .. py:class:: Context .. py:attribute:: output_dir :type: str :value: '' .. py:attribute:: logger :type: logging.Logger :value: None .. py:attribute:: apis :type: dict[str, steps.api.utils.api.Api] .. py:attribute:: cloud :type: steps.api.cloud.Cloud :value: None .. py:attribute:: request :type: steps.api.utils.api.Request :value: None .. py:attribute:: response :value: None .. py:function:: log_allure(title: str, text: str) -> None .. py:function:: attach_swagger_link(context: steps.api.utils.context.Context) .. py:function:: parse_nested_value(value, context) .. py:function:: try_read_from_variable(method: str, context) .. py:function:: try_save_value_to_variable(context, value, method: str) .. py:function:: check_expected_values_in_response(context, key: str, value: str)