def test_exclude_multiple(self): exclude_str = "httprunner|v2" har_parser = HarParser(self.har_path, exclude_str=exclude_str) teststeps = har_parser._prepare_teststeps() self.assertEqual(teststeps, []) exclude_str = "http2|v1" har_parser = HarParser(self.har_path, exclude_str=exclude_str) teststeps = har_parser._prepare_teststeps() self.assertEqual(teststeps, [])
def test_exclude(self): exclude_str = "debugtalk" har_parser = HarParser(self.har_path, exclude_str=exclude_str) teststeps = har_parser._prepare_teststeps() self.assertEqual( teststeps[0]["request"]["url"], "https://httprunner.top/api/v1/Account/Login", ) exclude_str = "httprunner" har_parser = HarParser(self.har_path, exclude_str=exclude_str) teststeps = har_parser._prepare_teststeps() self.assertEqual(teststeps, [])
def test_make_testcase(self): har_path = os.path.join(os.path.dirname(__file__), "data", "demo-quickstart.har") har_parser = HarParser(har_path) testcase = har_parser._make_testcase() self.assertIsInstance(testcase, dict) self.assertIn("config", testcase) self.assertIn("teststeps", testcase) self.assertEqual(len(testcase["teststeps"]), 2)
def main_har2case(args): har_source_file = args.har_source_file if not har_source_file or not har_source_file.endswith(".har"): logger.error("HAR file not specified.") sys.exit(1) if not os.path.isfile(har_source_file): logger.error(f"HAR file not exists: {har_source_file}") sys.exit(1) output_file_type = "YML" if args.to_yaml else "JSON" HarParser(har_source_file, args.filter, args.exclude).gen_testcase(output_file_type) return 0
def main_har2case(args): har_source_file = args.har_source_file if args.to_yaml: output_file_type = "YAML" elif args.to_json: output_file_type = "JSON" else: output_file_type = "pytest" capture_message(f"har2case {output_file_type}") HarParser(har_source_file, args.filter, args.exclude).gen_testcase(output_file_type) return 0
def main_har2case(args): har_source_file = args.har_source_file if not har_source_file or not har_source_file.endswith(".har"): logger.error("HAR file not specified.") sys.exit(1) har_source_file = ensure_path_sep(har_source_file) if not os.path.isfile(har_source_file): logger.error(f"HAR file not exists: {har_source_file}") sys.exit(1) if args.to_yaml: output_file_type = "YAML" elif args.to_json: output_file_type = "JSON" else: output_file_type = "pytest" capture_message(f"har2case {output_file_type}") HarParser(har_source_file, args.filter, args.exclude).gen_testcase(output_file_type) return 0
def setUp(self): self.har_path = os.path.join(os.path.dirname(__file__), "data", "demo.har") self.har_parser = HarParser(self.har_path)