def parse_xml_report(path_to_report): """This function parses the Tempest XML report and returns the list with TestResult objects. Each TestResult object corresponds to one of the tests and contains all the result information for the respective test. """ tree = ElementTree.parse(path_to_report) test_results = [] for elem in tree.findall('testcase'): status = 'passed' description = None child_elem = elem.getchildren() if child_elem: status = child_elem[0].tag description = child_elem[0].text test_result = report.TestResult( name=elem.get('name'), group=elem.get('classname'), status='failed' if status == 'failure' else status, description=description, duration=1) test_results.append(test_result) return test_results
def mark_all_tests_as_blocked(client, tests_suite): """This function marks all Tempest tests as blocked and returns the list with TestResult objects. Each TestResult object corresponds to one of the tests and contains the information that the test is blocked. """ test_results = [] for case in client.get_cases(tests_suite['id']): test_result = report.TestResult(name=case['title'], group=case['custom_test_group'], status='blocked', description=None, duration=1) test_results.append(test_result) return test_results