mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
add unittest for request with params
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
|
||||
name: 302 redirect
|
||||
request:
|
||||
url: https://httpbin.org/redirect-to?url=https%3A%2F%2Fdebugtalk.com&status_code=302
|
||||
# params:
|
||||
# url: https%3A%2F%2Fdebugtalk.com
|
||||
# status_code: 302
|
||||
url: https://httpbin.org/redirect-to
|
||||
params:
|
||||
url: https://debugtalk.com
|
||||
status_code: 302
|
||||
method: GET
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
|
||||
@@ -302,6 +302,21 @@ class TestHttpRunner(ApiServerUnittest):
|
||||
self.assertEqual(req_resp_data[0]["response"]["status_code"], 302)
|
||||
self.assertEqual(req_resp_data[1]["response"]["status_code"], 200)
|
||||
|
||||
def test_request_with_params(self):
|
||||
path = "tests/httpbin/api/302_redirect.yml"
|
||||
self.runner.run(path)
|
||||
summary = self.runner.summary
|
||||
self.assertTrue(summary["success"])
|
||||
self.assertEqual(summary["stat"]["testsRun"], 1)
|
||||
self.assertEqual(summary["stat"]["successes"], 1)
|
||||
|
||||
req_resp_data = summary["details"][0]["records"][0]["meta_datas"]["data"]
|
||||
self.assertEqual(len(req_resp_data), 2)
|
||||
self.assertEqual(
|
||||
req_resp_data[0]["request"]["url"],
|
||||
"https://httpbin.org/redirect-to?url=https%3A%2F%2Fdebugtalk.com&status_code=302"
|
||||
)
|
||||
|
||||
def test_run_testcase_hardcode(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
self.runner.run(testcase_file_path)
|
||||
|
||||
Reference in New Issue
Block a user