#169: add builtin support for uploading files

This commit is contained in:
debugtalk
2018-04-17 23:20:39 +08:00
parent 89f97d8b0a
commit ffff6fef52
7 changed files with 53 additions and 275 deletions

22
tests/httpbin/upload.yml Normal file
View File

@@ -0,0 +1,22 @@
- config:
name: test upload file with httpbin
request:
base_url: https://httpbin.org
- test:
name: upload file
variable_binds:
- field_name: "file"
- file_path: "LICENSE"
- file_type: "text/html"
- multipart_encoder: ${multipart_encoder($field_name, $file_path, $file_type)}
request:
url: /post
method: POST
headers:
Content-Type: ${multipart_content_type($multipart_encoder)}
data: $multipart_encoder
validators:
- eq: ["status_code", 200]
- startswith: ["content.files.file", "MIT License"]

View File

@@ -98,3 +98,11 @@ class TestHttpRunner(ApiServerUnittest):
self.assertTrue(summary["success"])
self.assertEqual(summary["stat"]["testsRun"], 2)
self.assertIn("records", summary)
def test_run_yaml_upload(self):
testset_path = "tests/httpbin/upload.yml"
runner = HttpRunner().run(testset_path)
summary = runner.summary
self.assertTrue(summary["success"])
self.assertEqual(summary["stat"]["testsRun"], 1)
self.assertIn("records", summary)