mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
test: add upload tests in v2 format
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
config:
|
||||||
|
name: test upload file with httpbin
|
||||||
|
base_url: ${get_httpbin_server()}
|
||||||
|
|
||||||
|
teststeps:
|
||||||
|
-
|
||||||
|
name: upload file
|
||||||
|
variables:
|
||||||
|
file_path: "data/test.env"
|
||||||
|
m_encoder: ${multipart_encoder(file=$file_path)}
|
||||||
|
request:
|
||||||
|
url: /post
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Content-Type: ${multipart_content_type($m_encoder)}
|
||||||
|
data: $m_encoder
|
||||||
|
validate:
|
||||||
|
- eq: ["status_code", 200]
|
||||||
|
- startswith: ["content.form.file", "data/test.env"]
|
||||||
|
|
||||||
@@ -6,13 +6,13 @@
|
|||||||
name: upload file
|
name: upload file
|
||||||
variables:
|
variables:
|
||||||
file_path: "data/test.env"
|
file_path: "data/test.env"
|
||||||
multipart_encoder: ${multipart_encoder(file=$file_path)}
|
m_encoder: ${multipart_encoder(file=$file_path)}
|
||||||
request:
|
request:
|
||||||
url: /post
|
url: /post
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
Content-Type: ${multipart_content_type($multipart_encoder)}
|
Content-Type: ${multipart_content_type($m_encoder)}
|
||||||
data: $multipart_encoder
|
data: $m_encoder
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- startswith: ["content.form.file", "data/test.env"]
|
- startswith: ["content.form.file", "data/test.env"]
|
||||||
|
|||||||
+11
-6
@@ -222,12 +222,17 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertIn("records", summary["details"][0])
|
self.assertIn("records", summary["details"][0])
|
||||||
|
|
||||||
def test_run_yaml_upload(self):
|
def test_run_yaml_upload(self):
|
||||||
summary = self.runner.run("tests/httpbin/upload.yml")
|
upload_cases_list = [
|
||||||
self.assertTrue(summary["success"])
|
"tests/httpbin/upload.yml",
|
||||||
self.assertEqual(summary["stat"]["testcases"]["total"], 1)
|
"tests/httpbin/upload.v2.yml"
|
||||||
self.assertEqual(summary["stat"]["teststeps"]["total"], 1)
|
]
|
||||||
self.assertIn("details", summary)
|
for upload_case in upload_cases_list:
|
||||||
self.assertIn("records", summary["details"][0])
|
summary = self.runner.run(upload_case)
|
||||||
|
self.assertTrue(summary["success"])
|
||||||
|
self.assertEqual(summary["stat"]["testcases"]["total"], 1)
|
||||||
|
self.assertEqual(summary["stat"]["teststeps"]["total"], 1)
|
||||||
|
self.assertIn("details", summary)
|
||||||
|
self.assertIn("records", summary["details"][0])
|
||||||
|
|
||||||
def test_run_post_data(self):
|
def test_run_post_data(self):
|
||||||
testcases = [
|
testcases = [
|
||||||
|
|||||||
Reference in New Issue
Block a user