docs: update changelog and example tests

This commit is contained in:
debugtalk
2020-06-03 18:48:56 +08:00
parent 06912b75b1
commit b11d2b349d
8 changed files with 125 additions and 251 deletions

View File

@@ -1,48 +1,27 @@
# NOTICE: Generated By HttpRunner. DO NOT EDIT!
# FROM: examples/httpbin/hooks.yml
from httprunner import HttpRunner, TConfig, TStep
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
class TestCaseHooks(HttpRunner):
config = TConfig(
**{
"name": "basic test with httpbin",
"base_url": "${get_httpbin_server()}",
"setup_hooks": ["${hook_print(setup)}"],
"teardown_hooks": ["${hook_print(teardown)}"],
"path": "examples/httpbin/hooks_test.py",
"variables": {},
}
)
config = Config("basic test with httpbin").base_url("${get_httpbin_server()}")
teststeps = [
TStep(
**{
"name": "headers",
"variables": {"a": 123},
"request": {"url": "/headers", "method": "GET"},
"setup_hooks": [
"${setup_hook_add_kwargs($request)}",
"${setup_hook_remove_kwargs($request)}",
],
"teardown_hooks": ["${teardown_hook_sleep_N_secs($response, 1)}"],
"validate": [
{"eq": ["status_code", 200]},
{"contained_by": ["body.headers.Host", "${get_httpbin_server()}"]},
],
}
Step(
RunRequest("headers")
.with_variables(**{"a": 123})
.get("/headers")
.validate()
.assert_equal("status_code", 200)
.assert_contained_by("body.headers.Host", "${get_httpbin_server()}")
),
TStep(
**{
"name": "alter response",
"request": {"url": "/headers", "method": "GET"},
"teardown_hooks": ["${alter_response($response)}"],
"validate": [
{"eq": ["status_code", 200]},
{"eq": ["body.headers.Host", "httpbin.org"]},
],
}
Step(
RunRequest("alter response")
.get("/headers")
.validate()
.assert_equal("status_code", 200)
.assert_equal("body.headers.Host", "httpbin.org")
),
]