har2case add profile args

This commit is contained in:
cyandragon88
2021-10-31 21:49:57 +08:00
parent 93b9fd8a23
commit 09a833d61b
4 changed files with 44 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ class TestHar(TestHar2CaseUtils):
def setUp(self):
self.har_path = os.path.join(os.path.dirname(__file__), "data", "demo.har")
self.har_parser = HarParser(self.har_path)
self.profile_path = os.path.join(os.path.dirname(__file__), "data", "profile.yml")
def test_prepare_teststep(self):
log_entries = load_har_log_entries(self.har_path)
@@ -47,6 +48,18 @@ class TestHar(TestHar2CaseUtils):
self.assertTrue(os.path.isfile(json_file))
os.remove(json_file)
def test_profile(self):
har_parser = HarParser(self.har_path, profile=self.profile_path)
teststeps = har_parser._prepare_teststeps()
self.assertEqual(
teststeps[0]["request"]["headers"],
{"Content-Type": "application/x-www-form-urlencoded"},
)
self.assertEqual(
teststeps[0]["request"]["cookies"],
{"CASTGC": "TGT"},
)
def test_filter(self):
filter_str = "httprunner"
har_parser = HarParser(self.har_path, filter_str)

View File

@@ -0,0 +1,4 @@
headers:
Content-Type: "application/x-www-form-urlencoded"
cookies:
CASTGC: "TGT"