How to use the catcher.utils.misc.fill_template_str function in catcher

To help you get started, we’ve selected a few catcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github comtihon / catcher / catcher / steps / kafka.py View on Github external
def __form_body(self, variables):
        data = self.data
        if data is None:
            data = read_file(fill_template_str(self.file, variables))
        return fill_template_str(data, variables)
github comtihon / catcher / catcher / steps / http.py View on Github external
def _form_request(self, url, variables: dict) -> dict:
        headers = dict([(fill_template_str(k, variables), fill_template_str(v, variables))
                        for k, v in self.headers.items()])
        rq = dict(verify=self.verify, headers=headers, files=self.__form_files(variables))
        isjson, body = self.__form_body(variables)
        debug('http ' + str(self.method) + ' ' + str(url) + ', ' + str(headers) + ', ' + str(body))
        content_type = self.__get_content_type(headers)
        if isjson or isinstance(body, dict):  # contains tojson or dict supplied
            if isinstance(body, dict) and content_type == 'application/json':
                # json body formed manually via python dict
                rq['json'] = body
            else:  # json string or form-data dict
                rq['data'] = body
        else:  # raw body (or body is None)
            rq['data'] = body
        rq['timeout'] = self.timeout
        return rq
github comtihon / catcher / catcher / core / holder.py View on Github external
def prepare_variables(self, test, global_variables: dict):
        """
        Create variables for test
        :param global_variables:
        :param test: test with test variables
        """
        # system env + inventory
        # (test template is filled in based on system, inventory & cmd vars)
        test.variables = try_get_object(fill_template_str(test.variables,
                                                          merge_two_dicts(global_variables, self._cmd_env)))
        # test local
        global_variables.update(test.variables)
        # include vars override test local
        global_variables.update(self._prepare_include_vars(test, global_variables))
        # cmd_env override everything
        global_variables.update(self._cmd_env)
        test.variables = global_variables
github comtihon / catcher / catcher / steps / external_step.py View on Github external
def simple_input(self, variables):
        """
        Use this method to get simple input as python object, with all
        templates filled in

        :param variables:
        :return: python object

        """
        json_args = fill_template_str(json.dumps(self.data), variables)
        return try_get_objects(json_args)