From 0158e98c8bcc3567d3678fd742ae3c3501a7deaa Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 1 Nov 2017 14:37:47 +0800 Subject: [PATCH] rename validators to validate --- README.md | 4 ++-- ate/runner.py | 7 +++--- docs/extraction-and-validation.md | 4 ++-- docs/quickstart.md | 14 +++++------ examples/quickstart-demo-rev-0.yml | 4 ++-- examples/quickstart-demo-rev-1.yml | 4 ++-- examples/quickstart-demo-rev-2.yml | 4 ++-- examples/quickstart-demo-rev-3.yml | 4 ++-- tests/api/demo.yml | 2 +- tests/data/demo_testset_hardcode.json | 6 ++--- tests/data/demo_testset_hardcode.yml | 6 ++--- tests/data/demo_testset_layer.yml | 24 +++++++++---------- ...demo_testset_template_import_functions.yml | 6 ++--- ...demo_testset_template_lambda_functions.yml | 6 ++--- tests/data/demo_testset_variables.yml | 6 ++--- tests/test_runner.py | 2 +- tests/test_testcase.py | 2 +- 17 files changed, 53 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 760b3f1e..1e82bc5f 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ And here is testset example of typical scenario: get `token` at the beginning, a sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -114,7 +114,7 @@ And here is testset example of typical scenario: get `token` at the beginning, a json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} ``` diff --git a/ate/runner.py b/ate/runner.py index 46210efc..2e4055af 100644 --- a/ate/runner.py +++ b/ate/runner.py @@ -86,7 +86,7 @@ class Runner(object): "body": '{"name": "user", "password": "123456"}' }, "extract": [], # optional - "validators": [], # optional + "validate": [], # optional "setup": [], # optional "teardown": [] # optional } @@ -104,7 +104,8 @@ class Runner(object): run_times = int(testcase.get("times", 1)) extractors = testcase.get("extract") \ or testcase.get("extract_binds", []) - validators = testcase.get("validators", []) + validators = testcase.get("validate") \ + or testcase.get("validators", []) setup_actions = testcase.get("setup", []) teardown_actions = testcase.get("teardown", []) @@ -157,7 +158,7 @@ class Runner(object): "variables": [], # optional, override "request": {}, "extract": {}, # optional - "validators": {} # optional + "validate": {} # optional }, testcase12 ] diff --git a/docs/extraction-and-validation.md b/docs/extraction-and-validation.md index e2abdba3..0e380f3c 100644 --- a/docs/extraction-and-validation.md +++ b/docs/extraction-and-validation.md @@ -24,7 +24,7 @@ Suppose we get the following HTTP response. } ``` -In `extract` and `validators`, we can do chain operation to extract data field in HTTP response. +In `extract` and `validate`, we can do chain operation to extract data field in HTTP response. For instance, if we want to get `Content-Type` in response headers, then we can specify `headers.content-type`; if we want to get `first_name` in response content, we can specify `content.person.name.first_name`. @@ -49,7 +49,7 @@ content.person.cities.1 extract: - content_type: headers.content-type - first_name: content.person.name.first_name -validators: +validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "headers.content-type", "expected": "application/json"} - {"check": "headers.content-length", "comparator": "gt", "expected": 40} diff --git a/docs/quickstart.md b/docs/quickstart.md index 6fe28976..c6b2783b 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -65,7 +65,7 @@ Open your favorite text editor and you can write test cases like this. json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} ``` @@ -122,7 +122,7 @@ To fix this problem, we should correlate `token` field in the second API test ca sign: 19067cf712265eb5426db8d3664026c1ccea02b9 extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -137,7 +137,7 @@ To fix this problem, we should correlate `token` field in the second API test ca json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} ``` @@ -204,7 +204,7 @@ And then, we can revise our demo test case and reference the functions. Suppose sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -219,7 +219,7 @@ And then, we can revise our demo test case and reference the functions. Suppose json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} ``` @@ -268,7 +268,7 @@ To handle this case, overall `config` block is supported in `ApiTestEngine`. If sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -282,7 +282,7 @@ To handle this case, overall `config` block is supported in `ApiTestEngine`. If json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} ``` diff --git a/examples/quickstart-demo-rev-0.yml b/examples/quickstart-demo-rev-0.yml index 1080d5eb..5580b17d 100644 --- a/examples/quickstart-demo-rev-0.yml +++ b/examples/quickstart-demo-rev-0.yml @@ -10,7 +10,7 @@ app_version: 2.8.6 json: sign: 19067cf712265eb5426db8d3664026c1ccea02b9 - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -25,6 +25,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} diff --git a/examples/quickstart-demo-rev-1.yml b/examples/quickstart-demo-rev-1.yml index 5884983b..0610615a 100644 --- a/examples/quickstart-demo-rev-1.yml +++ b/examples/quickstart-demo-rev-1.yml @@ -12,7 +12,7 @@ sign: 19067cf712265eb5426db8d3664026c1ccea02b9 extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -27,6 +27,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} diff --git a/examples/quickstart-demo-rev-2.yml b/examples/quickstart-demo-rev-2.yml index 5d403a97..c41a37f8 100644 --- a/examples/quickstart-demo-rev-2.yml +++ b/examples/quickstart-demo-rev-2.yml @@ -17,7 +17,7 @@ sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -32,6 +32,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} \ No newline at end of file diff --git a/examples/quickstart-demo-rev-3.yml b/examples/quickstart-demo-rev-3.yml index caae0485..952d2a59 100644 --- a/examples/quickstart-demo-rev-3.yml +++ b/examples/quickstart-demo-rev-3.yml @@ -24,7 +24,7 @@ sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -38,6 +38,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} diff --git a/tests/api/demo.yml b/tests/api/demo.yml index ee752e39..d256bc68 100644 --- a/tests/api/demo.yml +++ b/tests/api/demo.yml @@ -10,7 +10,7 @@ app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} diff --git a/tests/data/demo_testset_hardcode.json b/tests/data/demo_testset_hardcode.json index 0c89d885..08d72261 100644 --- a/tests/data/demo_testset_hardcode.json +++ b/tests/data/demo_testset_hardcode.json @@ -21,7 +21,7 @@ "token": "content.token" } ], - "validators": [ + "validate": [ {"check": "status_code", "comparator": "eq", "expected": 200}, {"check": "content.token", "comparator": "len_eq", "expected": 16} ] @@ -43,7 +43,7 @@ "password": "123456" } }, - "validators": [ + "validate": [ {"check": "status_code", "comparator": "eq", "expected": 201}, {"check": "content.success", "comparator": "eq", "expected": true} ] @@ -65,7 +65,7 @@ "password": "123456" } }, - "validators": [ + "validate": [ {"check": "status_code", "comparator": "eq", "expected": 500}, {"check": "content.success", "comparator": "eq", "expected": false} ] diff --git a/tests/data/demo_testset_hardcode.yml b/tests/data/demo_testset_hardcode.yml index 71061b91..7646e86f 100644 --- a/tests/data/demo_testset_hardcode.yml +++ b/tests/data/demo_testset_hardcode.yml @@ -13,7 +13,7 @@ sign: f1219719911caae89ccc301679857ebfda115ca2 extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -29,7 +29,7 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} @@ -45,6 +45,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 500} - {"check": "content.success", "comparator": "eq", "expected": false} \ No newline at end of file diff --git a/tests/data/demo_testset_layer.yml b/tests/data/demo_testset_layer.yml index 07514dd2..50328b6f 100644 --- a/tests/data/demo_testset_layer.yml +++ b/tests/data/demo_testset_layer.yml @@ -22,14 +22,14 @@ - test: name: reset all users api: reset_all($token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.success", "expected": true} - test: name: get user that does not exist api: get_user(1000, $token) - validators: + validate: - {"check": "status_code", "expected": 404} - {"check": "content.success", "expected": false} @@ -39,14 +39,14 @@ - user_name: "user1" - user_password: "123456" api: create_user(1000, $user_name, $user_password, $token) - validators: + validate: - {"check": "status_code", "expected": 201} - {"check": "content.success", "expected": true} - test: name: get user that has been created api: get_user(1000, $token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.success", "expected": true} - {"check": "content.data.password", "expected": "123456"} @@ -57,7 +57,7 @@ - user_name: "user1" - user_password: "123456" api: create_user(1000, $user_name, $user_password, $token) - validators: + validate: - {"check": "status_code", "expected": 500} - {"check": "content.success", "expected": false} @@ -67,14 +67,14 @@ - user_name: "user1" - user_password: "654321" api: update_user(1000, $user_name, $user_password, $token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.success", "expected": true} - test: name: get user that has been updated api: get_user(1000, $token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.success", "expected": true} - {"check": "content.data.password", "expected": "654321"} @@ -82,21 +82,21 @@ - test: name: get users api: get_users($token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.count", "expected": 1} - test: name: delete user that exists api: delete_user(1000, $token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.success", "expected": true} - test: name: get users api: get_users($token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.count", "expected": 0} @@ -106,13 +106,13 @@ - user_name: "user1" - user_password: "123456" api: create_user(1000, $user_name, $user_password, $token) - validators: + validate: - {"check": "status_code", "expected": 201} - {"check": "content.success", "expected": true} - test: name: get users api: get_users($token) - validators: + validate: - {"check": "status_code", "expected": 200} - {"check": "content.count", "expected": 1} diff --git a/tests/data/demo_testset_template_import_functions.yml b/tests/data/demo_testset_template_import_functions.yml index 9799d144..d786ecdf 100644 --- a/tests/data/demo_testset_template_import_functions.yml +++ b/tests/data/demo_testset_template_import_functions.yml @@ -27,7 +27,7 @@ sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -44,7 +44,7 @@ json: name: $user_name password: $user_password - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} @@ -58,6 +58,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 500} - {"check": "content.success", "comparator": "eq", "expected": false} diff --git a/tests/data/demo_testset_template_lambda_functions.yml b/tests/data/demo_testset_template_lambda_functions.yml index c45fb1b5..98321784 100644 --- a/tests/data/demo_testset_template_lambda_functions.yml +++ b/tests/data/demo_testset_template_lambda_functions.yml @@ -37,7 +37,7 @@ sign: ${get_sign_lambda($user_agent, $device_sn, $os_platform, $app_version)} extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -54,7 +54,7 @@ json: name: $user_name password: $user_password - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} @@ -68,6 +68,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 500} - {"check": "content.success", "comparator": "eq", "expected": false} diff --git a/tests/data/demo_testset_variables.yml b/tests/data/demo_testset_variables.yml index 116d2540..1efd6bb9 100644 --- a/tests/data/demo_testset_variables.yml +++ b/tests/data/demo_testset_variables.yml @@ -28,7 +28,7 @@ sign: $sign extract: - token: content.token - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 200} - {"check": "content.token", "comparator": "len_eq", "expected": 16} @@ -45,7 +45,7 @@ json: name: $user_name password: $user_password - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 201} - {"check": "content.success", "comparator": "eq", "expected": true} @@ -59,6 +59,6 @@ json: name: "user1" password: "123456" - validators: + validate: - {"check": "status_code", "comparator": "eq", "expected": 500} - {"check": "content.success", "comparator": "eq", "expected": false} diff --git a/tests/test_runner.py b/tests/test_runner.py index fcbf89d5..006d7256 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -56,7 +56,7 @@ class TestRunner(ApiServerUnittest): "extract": [ {"token": "content.token"} ], - "validators": [ + "validate": [ {"check": "status_code", "comparator": "eq", "expected": 205}, {"check": "content.token", "comparator": "len_eq", "expected": 19} ] diff --git a/tests/test_testcase.py b/tests/test_testcase.py index 0ef35482..5b7ffdf5 100644 --- a/tests/test_testcase.py +++ b/tests/test_testcase.py @@ -421,7 +421,7 @@ class TestcaseParserUnittest(unittest.TestCase): self.assertIn("request", testsets_list[0]["config"]) self.assertIn("request", testsets_list[0]["testcases"][0]) self.assertIn("url", testsets_list[0]["testcases"][0]["request"]) - self.assertIn("validators", testsets_list[0]["testcases"][0]) + self.assertIn("validate", testsets_list[0]["testcases"][0]) def test_substitute_variables_with_mapping(self): content = {