def xmind(case_type="testcase_json"): case_type_define = ["json", "zentao_csv", "testlink_xml", "testsuite_json", "testsuites", "testcase_json", "testcases"] xmind_file = 'static/files/BOOT3X_V3.9.0_V2.19.0.xmind' logger.info('Start to convert XMind file: %s' % xmind_file) if case_type == "testcase_json": testcase_json_file = xmind_testcase_to_json_file(xmind_file) logger.info('Convert XMind file to testcase json file successfully: %s', testcase_json_file) elif case_type == "zentao_csv": zentao_csv_file = xmind_to_zentao_csv_file(xmind_file) logger.info('Convert XMind file to zentao csv file successfully: %s', zentao_csv_file) elif case_type == "testlink_xml": testlink_xml_file = xmind_to_testlink_xml_file(xmind_file) logger.info('Convert XMind file to testlink xml file successfully: %s', testlink_xml_file) elif case_type == "testsuite_json": testsuite_json_file = xmind_testsuite_to_json_file(xmind_file) logger.info('Convert XMind file to testsuite json file successfully: %s', testsuite_json_file) elif case_type == "testsuites": testsuites = get_xmind_testsuite_list(xmind_file) logger.info('Convert XMind to testsuits dict data:\n%s',json.dumps(testsuites, indent=2, separators=(',', ': '), ensure_ascii=False)) elif case_type == "testcases": testcases = get_xmind_testcase_list(xmind_file) logger.info('Convert Xmind to testcases dict data:\n%s', json.dumps(testcases, indent=4, separators=(',', ': '))) elif case_type == "json": xmind_file = 'xmind_testcase_template.xmind' workbook = xmind.load(xmind_file) logger.info('Convert XMind to Json data:\n%s', json.dumps(workbook.getData(), indent=2, separators=(',', ': '), ensure_ascii=False)) logger.info('Finished conversion, Congratulations!') return True
def cli_main(): if len(sys.argv) > 1 and sys.argv[1].endswith('.xmind'): xmind_file = sys.argv[1] xmind_file = get_absolute_path(xmind_file) logging.info('Start to convert XMind file: %s', xmind_file) if len(sys.argv) == 3 and sys.argv[2] == '-json': testlink_json_file = xmind_testcase_to_json_file(xmind_file) logging.info( 'Convert XMind file to testcase json file successfully: %s', testlink_json_file) elif len(sys.argv) == 3 and sys.argv[2] == '-xml': testlink_xml_file = xmind_to_testlink_xml_file(xmind_file) logging.info( 'Convert XMind file to testlink xml files successfully: %s', testlink_xml_file) elif len(sys.argv) == 3 and sys.argv[2] == '-csv': zentao_csv_file = xmind_to_zentao_csv_file(xmind_file) logging.info( 'Convert XMind file to zentao csv file successfully: %s', zentao_csv_file) else: testlink_json_file = xmind_testcase_to_json_file(xmind_file) testlink_xml_file = xmind_to_testlink_xml_file(xmind_file) zentao_csv_file = xmind_to_zentao_csv_file(xmind_file) logging.info( 'Convert XMind file successfully: \n' '1、 testcase json file(%s)\n' '2、 testlink xml file(%s)\n' '3、 zentao csv file(%s)', testlink_json_file, testlink_xml_file, zentao_csv_file) elif len(sys.argv) > 1 and sys.argv[1] == 'webtool': if len(sys.argv) == 3: try: port = int(sys.argv[2]) launch(port=port) except ValueError: launch() else: launch() else: print(__doc__) logging.error('%s', __doc__)
def download_zentao_file(filename): full_path = join(app.config['UPLOAD_FOLDER'], filename) if not exists(full_path): abort(404) zentao_csv_file = xmind_to_zentao_csv_file(full_path) filename = os.path.basename(zentao_csv_file) if zentao_csv_file else abort(404) return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True)
def main(): xmind_file = 'docs/xmind_testcase_template_v1.1.xmind' print('Start to convert XMind file: %s' % xmind_file) # 1、testcases import file # (1) zentao zentao_csv_file = xmind_to_zentao_csv_file(xmind_file) print('Convert XMind file to zentao csv file successfully: %s' % zentao_csv_file) # (2) testlink testlink_xml_file = xmind_to_testlink_xml_file(xmind_file) print('Convert XMind file to testlink xml file successfully: %s' % testlink_xml_file) # 2、 testcases json file # (1) testsuite testsuite_json_file = xmind_testsuite_to_json_file(xmind_file) print('Convert XMind file to testsuite json file successfully: %s' % testsuite_json_file) # (2) testcase testcase_json_file = xmind_testcase_to_json_file(xmind_file) print('Convert XMind file to testcase json file successfully: %s' % testcase_json_file) # 3、test dict/json data # (1) testsuite testsuites = get_xmind_testsuite_list(xmind_file) print('Convert XMind to testsuits dict data:\n%s' % json.dumps( testsuites, indent=2, separators=(',', ': '), ensure_ascii=False)) # (2) testcase testcases = get_xmind_testcase_list(xmind_file) print('Convert Xmind to testcases dict data:\n%s' % json.dumps( testcases, indent=4, separators=(',', ': '), ensure_ascii=False)) # (3) xmind file workbook = xmind.load(xmind_file) print('Convert XMind to Json data:\n%s' % json.dumps(workbook.getData(), indent=2, separators=(',', ': '), ensure_ascii=False)) print('Finished conversion, Congratulations!')
def xmind(case_type="testcase_json"): case_type_define = [ "json", "zentao_csv", "testlink_xml", "testsuite_json", "testsuites", "testcase_json", "testcases" ] xmind_file = 'docs/xmind_testcase_template.xmind' print('Start to convert XMind file: %s' % xmind_file) if case_type == "testcase_json": testcase_json_file = xmind_testcase_to_json_file(xmind_file) print('Convert XMind file to testcase json file successfully: %s' % testcase_json_file) elif case_type == "zentao_csv": zentao_csv_file = xmind_to_zentao_csv_file(xmind_file) print('Convert XMind file to zentao csv file successfully: %s' % zentao_csv_file) elif case_type == "testlink_xml": testlink_xml_file = xmind_to_testlink_xml_file(xmind_file) print('Convert XMind file to testlink xml file successfully: %s' % testlink_xml_file) elif case_type == "testsuite_json": testsuite_json_file = xmind_testsuite_to_json_file(xmind_file) print('Convert XMind file to testsuite json file successfully: %s' % testsuite_json_file) elif case_type == "testsuites": testsuites = get_xmind_testsuite_list(xmind_file) print('Convert XMind to testsuits dict data:\n%s' % json.dumps( testsuites, indent=2, separators=(',', ': '), ensure_ascii=False)) elif case_type == "testcases": testcases = get_xmind_testcase_list(xmind_file) print('Convert Xmind to testcases dict data:\n%s' % json.dumps(testcases, indent=4, separators=(',', ': '))) elif case_type == "json": workbook = xmind.load(xmind_file) print('Convert XMind to Json data:\n%s' % json.dumps(workbook.getData(), indent=2, separators=(',', ': '), ensure_ascii=False)) print('Finished conversion, Congratulations!')