mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-05 15:59:33 +08:00
update: httprunner make v4
This commit is contained in:
@@ -26,6 +26,53 @@ class TestCompat(unittest.TestCase):
|
||||
with self.assertRaises(exceptions.TestCaseFormatError):
|
||||
compat.convert_variables(None, "examples/data/a-b.c/1.yml")
|
||||
|
||||
def test_convert_request(self):
|
||||
request_with_json_body = {
|
||||
"method": "POST",
|
||||
"url": "https://postman-echo.com/post",
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"k1": "v1",
|
||||
"k2": "v2"
|
||||
}
|
||||
}
|
||||
self.assertEqual(
|
||||
compat._convert_request(request_with_json_body),
|
||||
{
|
||||
"method": "POST",
|
||||
"url": "https://postman-echo.com/post",
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"k1": "v1",
|
||||
"k2": "v2"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
request_with_text_body = {
|
||||
"method": "POST",
|
||||
"url": "https://postman-echo.com/post",
|
||||
"headers": {
|
||||
"Content-Type": "text/plain"
|
||||
},
|
||||
"body": "have a nice day"
|
||||
}
|
||||
self.assertEqual(
|
||||
compat._convert_request(request_with_text_body),
|
||||
{
|
||||
"method": "POST",
|
||||
"url": "https://postman-echo.com/post",
|
||||
"headers": {
|
||||
"Content-Type": "text/plain"
|
||||
},
|
||||
"data": "have a nice day"
|
||||
}
|
||||
)
|
||||
|
||||
def test_convert_jmespath(self):
|
||||
self.assertEqual(compat._convert_jmespath("content.abc"), "body.abc")
|
||||
self.assertEqual(compat._convert_jmespath("json.abc"), "body.abc")
|
||||
@@ -85,7 +132,7 @@ class TestCompat(unittest.TestCase):
|
||||
[{"eq": ["body[0].name", 201]}],
|
||||
)
|
||||
|
||||
def test_ensure_testcase_v3_api(self):
|
||||
def test_ensure_testcase_v4_api(self):
|
||||
api_content = {
|
||||
"name": "get with params",
|
||||
"request": {
|
||||
@@ -98,7 +145,7 @@ class TestCompat(unittest.TestCase):
|
||||
"validate": [{"eq": ["content.varB", 200]}, {"lt": ["json.0.varC", 0]}],
|
||||
}
|
||||
self.assertEqual(
|
||||
compat.ensure_testcase_v3_api(api_content),
|
||||
compat.ensure_testcase_v4_api(api_content),
|
||||
{
|
||||
"config": {
|
||||
"name": "get with params",
|
||||
@@ -126,7 +173,7 @@ class TestCompat(unittest.TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
def test_ensure_testcase_v3(self):
|
||||
def test_ensure_testcase_v4(self):
|
||||
testcase_content = {
|
||||
"config": {"name": "xxx", "base_url": "https://httpbin.org"},
|
||||
"teststeps": [
|
||||
@@ -150,7 +197,7 @@ class TestCompat(unittest.TestCase):
|
||||
],
|
||||
}
|
||||
self.assertEqual(
|
||||
compat.ensure_testcase_v3(testcase_content),
|
||||
compat.ensure_testcase_v4(testcase_content),
|
||||
{
|
||||
"config": {"name": "xxx", "base_url": "https://httpbin.org"},
|
||||
"teststeps": [
|
||||
|
||||
Reference in New Issue
Block a user