def test_parse_xmind_auto(): v1 = parser.xmind_to_suite(xmind_v1_file) cache.clear() exp = parser.xmind_to_suite_v1(xmind_v1_file) assert v1.to_dict() == exp.to_dict() v2 = parser.xmind_to_suite(xmind_v2_file) cache.clear() exp = parser.xmind_to_suite_v2(xmind_v2_file) assert v2.to_dict() == exp.to_dict()
def main(xacpt, jira_token, project_name_key, xmind, is_smoketest, testcase_type, folder_name=None): # xacpt = '' # jira_token = 'XWGNZ4MgoeD1kfofTelQ72CD' # project_name_key = 'QUARD' # xmind = '/Users/wei.zhou/Documents/4x版本迭代/spirnt06/Kyligence Enterprise-sprint06.xmind' suite = xmind_to_suite(xmind) xray_issue = XrayIssue(xacpt, jira_token) xray_issue.get_folder_id(project_name_key) # csv_file = generate_csv_title(xmind) for test_suit in suite.sub_suites: components = test_suit.name issue_ids = [] for test_case in test_suit.testcase_list: test_case_name = test_case.name title_name = test_suit.name + ' > ' + test_case_name # generate_tm4j_csv(csv_file, title_name, test_case, get_issue_key(test_case_name), sub_title) issue_id = xray_issue.create_xray_full_issue(project_name_key, title_name, test_case, get_issue_key(test_case_name), components, is_smoketest, testcase_type) issue_ids.append(issue_id) forder_name = components if folder_name is None else folder_name xray_issue.move_issue_to_folder(issue_ids, project_name_key, forder_name) # for test_case in test_suit print()
def main(xacpt, jira_token, project_name_key, xmind): suite = xmind_to_suite(xmind) for test_suit in suite.sub_suites: sub_title = test_suit.name for test_case in test_suit.testcase_list: test_case_name = test_case.name title_name = sub_title + ' > ' + test_case_name xray_issue.create_xray_full_issue(project_name_key, title_name, test_case, get_issue_key(test_case_name), jira_token, xacpt) # for test_case in test_suit print()
def main(xacpt, jira_token, project_name_key, xmind): # xacpt = '' # jira_token = 'XWGNZ4MgoeD1kfofTelQ72CD' # project_name_key = 'QUARD' # xmind = '/Users/wei.zhou/Documents/4x版本迭代/spirnt06/Kyligence Enterprise-sprint06.xmind' suite = xmind_to_suite(xmind) for test_suit in suite.sub_suites: sub_title = test_suit.name for test_case in test_suit.testcase_list: test_case_name = test_case.name title_name = sub_title + ' > ' + test_case_name xray_issue.create_xray_full_issue(project_name_key, title_name, test_case, get_issue_key(test_case_name), jira_token, xacpt) # for test_case in test_suit print()
def xmind_to_testlink(xmind): xml_out = xmind[:-5] + 'xml' suite = xmind_to_suite(xmind) to_testlink_xml_file(suite, xml_out) return xml_out
def xmindtest(xmind): xmind_to_suite(xmind)
def main(xacpt, jira_token, project_name_key, xmind, is_smoketest, is_need_quard, testcase_type, folder_name=None, error_case_file=None, xray_client_id=None, xray_client_key=None): # xacpt = '' # jira_token = 'XWGNZ4MgoeD1kfofTelQ72CD' # project_name_key = 'QUARD' # xmind = '/Users/wei.zhou/Documents/4x版本迭代/spirnt06/Kyligence Enterprise-sprint06.xmind' suite = xmind_to_suite(xmind) xray_issue = XrayIssue(xacpt, jira_token, xray_client_id, xray_client_key) if xacpt != '': xray_issue.get_folder_id(project_name_key) # csv_file = generate_csv_title(xmind) error_case_file = '/tmp/error_case_file.txt' if error_case_file is None else error_case_file if os.path.isdir(error_case_file): error_case_file = os.path.join(error_case_file, 'error_case_file.txt') if os.path.exists(error_case_file): os.remove(error_case_file) for test_suit in suite.sub_suites: if xray_client_id is None and xray_client_key is None and xacpt != '': components = test_suit.name for test_case in test_suit.testcase_list: test_case_name = test_case.name title_name = test_suit.name + ' > ' + test_case_name # generate_tm4j_csv(csv_file, title_name, test_case, get_issue_key(test_case_name), sub_title) try: issue_id = xray_issue.create_xray_full_issue( project_name_key, title_name, test_case, get_issue_key(test_case_name), components, is_smoketest, is_need_quard, testcase_type) except Exception: issue_id = None with open(error_case_file, 'a+') as f: f.write('{} create failed\n'.format(test_case_name)) traceback.format_exc() if issue_id: forder_name = components if folder_name is None else folder_name xray_issue.move_issue_to_folder([issue_id], project_name_key, forder_name) elif xray_client_id is not None and xray_client_key is not None: components = get_compenent(test_suit.name) bulk_json_arr = [] for test_case in test_suit.testcase_list: test_case_name = test_case.name title_name = components + ' > ' + test_case_name bulk_json = xray_issue.generate_bulk_json( project_name_key, title_name, test_case, get_issue_key(test_case_name), components, is_smoketest, is_need_quard, testcase_type, test_suit.name) bulk_json_arr.append(bulk_json) job_id = xray_issue.bulk_xray_issue(bulk_json_arr) print(job_id) result = xray_issue.await_import_bulk_xray_issue(job_id) print(result) if result.get('result').get('errors'): with open(error_case_file, 'a+') as f: for error in result.get('result').get('errors'): f.write('{} create failed. '.format( bulk_json_arr[error.get('elementNumber')].get( 'fields').get('summary'))) f.write('The reason is {}!\n'.format( error.get('errors'))) print()
from tests.test_xmind_parser import xmind_v1_file from xmind2testlink.testlink_parser import * from xmind2testlink.xmind_parser import xmind_to_suite test_suite = xmind_to_suite(xmind_v1_file) test_link_xml = 'testlink.xml' def test_to_testlink_xml(): if exists(test_link_xml): os.remove(test_link_xml) to_testlink_xml_file(test_suite, test_link_xml) with open(test_link_xml) as f: content = f.read() assert "apple suite" in content assert "my test case 2" in content assert "expected something" in content assert "only with precondition" in content assert "summary of test case" in content assert "ignore me" not in content assert "<importance>3</importance>" in content os.remove(test_link_xml)
def test_parse_xmind_file(): if enabled: out = parser.xmind_to_suite(xmind) print(out)
def test_flat_suite(): test_suite = parser.xmind_to_suite(xmind_v2_file) out = flat_suite(test_suite) print(dumps(out, indent=2))