def test_defaultValues(self): element = JSONExtractor(defaultValues='default') rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc,'test_result')) for tag in parsed_doc['test_result']['JSONPostProcessor']['stringProp']: if tag['@name'] == 'JSONPostProcessor.defaultValues': assert tag['#text'] == 'default'
def test_scope1(self): element = JSONExtractor(scope=Scope.MAIN_AND_SUB) rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc,'test_result')) for tag in parsed_doc['test_result']['JSONPostProcessor']['stringProp']: if tag['@name'] == 'Sample.scop': assert tag['#text'] == 'all'
def test_match_numbers(self): element = JSONExtractor(match_numbers=0) rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc,'test_result')) for tag in parsed_doc['test_result']['JSONPostProcessor']['stringProp']: if tag['@name'] == 'JSONPostProcessor.match_numbers': assert tag['#text'] == '0'
def test_jsonPathExprs(self): element = JSONExtractor(jsonPathExprs='expr[*].result') rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc,'test_result')) for tag in parsed_doc['test_result']['JSONPostProcessor']['stringProp']: if tag['@name'] == 'JSONPostProcessor.jsonPathExprs': assert tag['#text'] == 'expr[*].result'
def test_scope2(self): element = JSONExtractor(scope='var_name') rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc, 'test_result')) for tag in parsed_doc['test_result']['JSONPostProcessor'][ 'stringProp']: if tag['@name'] == 'Sample.scope': assert tag['#text'] == 'variable' if tag['@name'] == 'Scope.variable': assert tag['#text'] == 'var_name'
def test_hashtree_contain(self): element = JSONExtractor() rendered_doc = tag_wrapper(element.to_xml(), 'result') assert '<hashTree />' in rendered_doc
def test_compute_concat(self): element = JSONExtractor(compute_concat=True) rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc, 'test_result')) assert parsed_doc['test_result']['JSONPostProcessor']['boolProp'][ '#text'] == 'true'