diff --git a/examples/httpbin/basic_test.py b/examples/httpbin/basic_test.py index 5565c15e..c16102bb 100644 --- a/examples/httpbin/basic_test.py +++ b/examples/httpbin/basic_test.py @@ -1,4 +1,4 @@ -# NOTE: Generated By HttpRunner v3.1.4 +# NOTE: Generated By HttpRunner v3.1.7 # FROM: basic.yml diff --git a/examples/httpbin/hooks_test.py b/examples/httpbin/hooks_test.py index 832b3b17..ef4fce08 100644 --- a/examples/httpbin/hooks_test.py +++ b/examples/httpbin/hooks_test.py @@ -1,4 +1,4 @@ -# NOTE: Generated By HttpRunner v3.1.4 +# NOTE: Generated By HttpRunner v3.1.7 # FROM: hooks.yml diff --git a/examples/httpbin/load_image_test.py b/examples/httpbin/load_image_test.py index 61b05f3f..a3827b85 100644 --- a/examples/httpbin/load_image_test.py +++ b/examples/httpbin/load_image_test.py @@ -1,4 +1,4 @@ -# NOTE: Generated By HttpRunner v3.1.4 +# NOTE: Generated By HttpRunner v3.1.7 # FROM: load_image.yml diff --git a/examples/httpbin/upload_test.py b/examples/httpbin/upload_test.py index 134a5575..c3886e0c 100644 --- a/examples/httpbin/upload_test.py +++ b/examples/httpbin/upload_test.py @@ -1,4 +1,4 @@ -# NOTE: Generated By HttpRunner v3.1.4 +# NOTE: Generated By HttpRunner v3.1.7 # FROM: upload.yml diff --git a/examples/httpbin/validate_test.py b/examples/httpbin/validate_test.py index 87b16aa7..c6ddd3f9 100644 --- a/examples/httpbin/validate_test.py +++ b/examples/httpbin/validate_test.py @@ -1,4 +1,4 @@ -# NOTE: Generated By HttpRunner v3.1.4 +# NOTE: Generated By HttpRunner v3.1.7 # FROM: validate.yml diff --git a/examples/postman_echo/cookie_manipulation/__init__.py b/examples/postman_echo/cookie_manipulation/__init__.py new file mode 100644 index 00000000..70cfba53 --- /dev/null +++ b/examples/postman_echo/cookie_manipulation/__init__.py @@ -0,0 +1 @@ +# NOTICE: Generated By HttpRunner. DO NOT EDIT! diff --git a/examples/postman_echo/cookie_manipulation/hardcode.yml b/examples/postman_echo/cookie_manipulation/hardcode.yml index f81c5f7c..d3b00354 100644 --- a/examples/postman_echo/cookie_manipulation/hardcode.yml +++ b/examples/postman_echo/cookie_manipulation/hardcode.yml @@ -2,7 +2,7 @@ config: name: "set & delete cookies." base_url: "https://postman-echo.com" verify: False - export: ["cookie_foo1", "cookie_foo3"] + export: ["cookie_foo1"] teststeps: - @@ -16,10 +16,11 @@ teststeps: headers: User-Agent: HttpRunner/${get_httprunner_version()} extract: - cookie_foo1: $.cookies.foo1 + cookie_foo1: body.cookies.foo1 validate: - eq: ["status_code", 200] - - eq: ["cookies.foo1", "bar1"] + - eq: ["body.cookies.foo1", "bar1"] + - eq: ["body.cookies.foo2", "bar2"] - name: delete cookie foo2 request: @@ -29,6 +30,5 @@ teststeps: User-Agent: HttpRunner/${get_httprunner_version()} validate: - eq: ["status_code", 200] - - ne: ["$.cookies.foo1", "$foo1"] - - eq: ["$.cookies.foo1", "$cookie_foo1"] - - eq: ["$.cookies.foo3", "$cookie_foo3"] + - eq: ["body.cookies.foo1", "bar1"] + - eq: ["body.cookies.foo2", null] diff --git a/examples/postman_echo/cookie_manipulation/hardcode_test.py b/examples/postman_echo/cookie_manipulation/hardcode_test.py new file mode 100644 index 00000000..b69b0e40 --- /dev/null +++ b/examples/postman_echo/cookie_manipulation/hardcode_test.py @@ -0,0 +1,43 @@ +# NOTE: Generated By HttpRunner v3.1.7 +# FROM: cookie_manipulation/hardcode.yml + + +from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase + + +class TestCaseHardcode(HttpRunner): + + config = ( + Config("set & delete cookies.") + .base_url("https://postman-echo.com") + .verify(False) + .export(*["cookie_foo1"]) + ) + + teststeps = [ + Step( + RunRequest("set cookie foo1 & foo2 & foo3") + .get("/cookies/set") + .with_params(**{"foo1": "bar1", "foo2": "bar2"}) + .with_headers(**{"User-Agent": "HttpRunner/${get_httprunner_version()}"}) + .extract() + .with_jmespath("body.cookies.foo1", "cookie_foo1") + .validate() + .assert_equal("status_code", 200) + .assert_equal("body.cookies.foo1", "bar1") + .assert_equal("body.cookies.foo2", "bar2") + ), + Step( + RunRequest("delete cookie foo2") + .get("/cookies/delete?foo2") + .with_headers(**{"User-Agent": "HttpRunner/${get_httprunner_version()}"}) + .validate() + .assert_equal("status_code", 200) + .assert_equal("body.cookies.foo1", "bar1") + .assert_equal("body.cookies.foo2", None) + ), + ] + + +if __name__ == "__main__": + TestCaseHardcode().test_start() diff --git a/examples/postman_echo/cookie_manipulation/set_delete_cookies_test.py b/examples/postman_echo/cookie_manipulation/set_delete_cookies_test.py new file mode 100644 index 00000000..77347c7a --- /dev/null +++ b/examples/postman_echo/cookie_manipulation/set_delete_cookies_test.py @@ -0,0 +1,46 @@ +# NOTE: Generated By HttpRunner v3.1.7 +# FROM: cookie_manipulation/set_delete_cookies.yml + + +from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase + + +class TestCaseSetDeleteCookies(HttpRunner): + + config = ( + Config("set & delete cookies.") + .variables(**{"foo1": "bar1", "foo2": "bar2"}) + .base_url("https://postman-echo.com") + .verify(False) + .export(*["cookie_foo1", "cookie_foo3"]) + ) + + teststeps = [ + Step( + RunRequest("set cookie foo1 & foo2 & foo3") + .with_variables(**{"foo3": "bar3"}) + .get("/cookies/set") + .with_params(**{"foo1": "bar111", "foo2": "$foo2", "foo3": "$foo3"}) + .with_headers(**{"User-Agent": "HttpRunner/${get_httprunner_version()}"}) + .extract() + .with_jmespath("$.cookies.foo1", "cookie_foo1") + .with_jmespath("$.cookies.foo3", "cookie_foo3") + .validate() + .assert_equal("status_code", 200) + .assert_not_equal("$.cookies.foo3", "$foo3") + ), + Step( + RunRequest("delete cookie foo2") + .get("/cookies/delete?foo2") + .with_headers(**{"User-Agent": "HttpRunner/${get_httprunner_version()}"}) + .validate() + .assert_equal("status_code", 200) + .assert_not_equal("$.cookies.foo1", "$foo1") + .assert_equal("$.cookies.foo1", "$cookie_foo1") + .assert_equal("$.cookies.foo3", "$cookie_foo3") + ), + ] + + +if __name__ == "__main__": + TestCaseSetDeleteCookies().test_start()