mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 14:59:38 +08:00
docs: update changelog and example tests
This commit is contained in:
@@ -1,43 +1,28 @@
|
||||
# NOTICE: Generated By HttpRunner. DO NOT EDIT!
|
||||
# FROM: examples/httpbin/validate.yml
|
||||
|
||||
from httprunner import HttpRunner, TConfig, TStep
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
class TestCaseValidate(HttpRunner):
|
||||
config = TConfig(
|
||||
**{
|
||||
"name": "basic test with httpbin",
|
||||
"base_url": "http://httpbin.org/",
|
||||
"path": "examples/httpbin/validate_test.py",
|
||||
"variables": {},
|
||||
}
|
||||
)
|
||||
config = Config("basic test with httpbin").base_url("http://httpbin.org/")
|
||||
|
||||
teststeps = [
|
||||
TStep(
|
||||
**{
|
||||
"name": "validate response with json path",
|
||||
"request": {"url": "/get", "params": {"a": 1, "b": 2}, "method": "GET"},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["body.args.a", 1]},
|
||||
{"eq": ["body.args.b", 2]},
|
||||
],
|
||||
"validate_script": ["assert status_code == 200"],
|
||||
}
|
||||
Step(
|
||||
RunRequest("validate response with json path")
|
||||
.get("/get")
|
||||
.with_params(**{"a": 1, "b": 2})
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
.assert_equal("body.args.a", "1")
|
||||
.assert_equal("body.args.b", "2")
|
||||
),
|
||||
TStep(
|
||||
**{
|
||||
"name": "validate response with python script",
|
||||
"request": {"url": "/get", "params": {"a": 1, "b": 2}, "method": "GET"},
|
||||
"validate": [{"eq": ["status_code", 200]}],
|
||||
"validate_script": [
|
||||
"assert status_code == 201",
|
||||
"a = response_json.get('args').get('a')",
|
||||
"assert a == '1'",
|
||||
],
|
||||
}
|
||||
Step(
|
||||
RunRequest("validate response with python script")
|
||||
.get("/get")
|
||||
.with_params(**{"a": 1, "b": 2})
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user