예제 #1
0
class SpecEvaluator:
    def __init__(self, api_tree):
        self.api_tree = api_tree
        self.string_evaluator = StringEvaluator(self)

    def evaluate(self, element):
        if isinstance(element, dict):
            return self.evaluate_dict(element)

        if isinstance(element, list):
            return self.evaluate_list(element)

        if not isinstance(element, str):
            return element

        return self.string_evaluator.evaluate(element)

    def evaluate_dict(self, element):
        evaluated_dict = {}
        for key, value in element.items():
            evaluated_dict[key] = self.evaluate(value)

        return evaluated_dict

    def evaluate_list(self, elements):
        evaluated_list = []
        for item in elements:
            evaluated_list.append(self.evaluate(item))

        return evaluated_list
예제 #2
0
def _evaluate_str(element, spec_vars, is_a_test_case=False):
    return StringEvaluator.evaluate(element, spec_vars, is_a_test_case)
예제 #3
0
def _evaluate_str(element, vars):
    return StringEvaluator.evaluate(element, vars)