From 9bd28653f6582bddc6da51cc8cd9b901305a88dc Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 1 Nov 2017 14:30:36 +0800 Subject: [PATCH] rename extractor/extractors to extract --- README.md | 2 +- ate/runner.py | 7 +++---- docs/extraction-and-validation.md | 4 ++-- docs/quickstart.md | 8 ++++---- examples/quickstart-demo-rev-1.yml | 2 +- examples/quickstart-demo-rev-2.yml | 2 +- examples/quickstart-demo-rev-3.yml | 2 +- tests/data/demo_testset_hardcode.json | 2 +- tests/data/demo_testset_hardcode.yml | 2 +- tests/data/demo_testset_layer.yml | 2 +- tests/data/demo_testset_template_import_functions.yml | 2 +- tests/data/demo_testset_template_lambda_functions.yml | 2 +- tests/data/demo_testset_variables.yml | 2 +- tests/test_runner.py | 2 +- 14 files changed, 20 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8d258f28..760b3f1e 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ And here is testset example of typical scenario: get `token` at the beginning, a app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/ate/runner.py b/ate/runner.py index c406367f..46210efc 100644 --- a/ate/runner.py +++ b/ate/runner.py @@ -85,7 +85,7 @@ class Runner(object): }, "body": '{"name": "user", "password": "123456"}' }, - "extractors": [], # optional + "extract": [], # optional "validators": [], # optional "setup": [], # optional "teardown": [] # optional @@ -102,8 +102,7 @@ class Runner(object): raise exception.ParamsError("URL or METHOD missed!") run_times = int(testcase.get("times", 1)) - extractors = testcase.get("extractors") \ - or testcase.get("extractor") \ + extractors = testcase.get("extract") \ or testcase.get("extract_binds", []) validators = testcase.get("validators", []) setup_actions = testcase.get("setup", []) @@ -157,7 +156,7 @@ class Runner(object): "name": "testcase description", "variables": [], # optional, override "request": {}, - "extractors": {}, # optional + "extract": {}, # optional "validators": {} # optional }, testcase12 diff --git a/docs/extraction-and-validation.md b/docs/extraction-and-validation.md index 0cb76fc0..e2abdba3 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 `extractors` and `validators`, we can do chain operation to extract data field in HTTP response. +In `extract` and `validators`, 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`. @@ -46,7 +46,7 @@ content.person.cities.1 ``` ```yaml -extractors: +extract: - content_type: headers.content-type - first_name: content.person.name.first_name validators: diff --git a/docs/quickstart.md b/docs/quickstart.md index f1756da9..6fe28976 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -120,7 +120,7 @@ To fix this problem, we should correlate `token` field in the second API test ca app_version: 2.8.6 json: sign: 19067cf712265eb5426db8d3664026c1ccea02b9 - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} @@ -142,7 +142,7 @@ To fix this problem, we should correlate `token` field in the second API test ca - {"check": "content.success", "comparator": "eq", "expected": true} ``` -As you see, the `token` field is no longer hardcoded, instead it is extracted from the first API request with `extractors` mechanism. In the meanwhile, it is assigned to `token` variable, which can be referenced by the subsequent API requests. +As you see, the `token` field is no longer hardcoded, instead it is extracted from the first API request with `extract` mechanism. In the meanwhile, it is assigned to `token` variable, which can be referenced by the subsequent API requests. Now we save the test cases to [`quickstart-demo-rev-1.yml`][quickstart-demo-rev-1] and rerun it, and we will find that both API requests to be successful. @@ -202,7 +202,7 @@ And then, we can revise our demo test case and reference the functions. Suppose app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} @@ -266,7 +266,7 @@ To handle this case, overall `config` block is supported in `ApiTestEngine`. If app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/examples/quickstart-demo-rev-1.yml b/examples/quickstart-demo-rev-1.yml index d203cf8a..5884983b 100644 --- a/examples/quickstart-demo-rev-1.yml +++ b/examples/quickstart-demo-rev-1.yml @@ -10,7 +10,7 @@ app_version: 2.8.6 json: sign: 19067cf712265eb5426db8d3664026c1ccea02b9 - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/examples/quickstart-demo-rev-2.yml b/examples/quickstart-demo-rev-2.yml index 7b2282f8..5d403a97 100644 --- a/examples/quickstart-demo-rev-2.yml +++ b/examples/quickstart-demo-rev-2.yml @@ -15,7 +15,7 @@ app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/examples/quickstart-demo-rev-3.yml b/examples/quickstart-demo-rev-3.yml index cb937011..caae0485 100644 --- a/examples/quickstart-demo-rev-3.yml +++ b/examples/quickstart-demo-rev-3.yml @@ -22,7 +22,7 @@ app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/tests/data/demo_testset_hardcode.json b/tests/data/demo_testset_hardcode.json index bd154933..0c89d885 100644 --- a/tests/data/demo_testset_hardcode.json +++ b/tests/data/demo_testset_hardcode.json @@ -16,7 +16,7 @@ "sign": "f1219719911caae89ccc301679857ebfda115ca2" } }, - "extractors": [ + "extract": [ { "token": "content.token" } diff --git a/tests/data/demo_testset_hardcode.yml b/tests/data/demo_testset_hardcode.yml index 2b112e36..71061b91 100644 --- a/tests/data/demo_testset_hardcode.yml +++ b/tests/data/demo_testset_hardcode.yml @@ -11,7 +11,7 @@ app_version: '2.8.6' json: sign: f1219719911caae89ccc301679857ebfda115ca2 - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/tests/data/demo_testset_layer.yml b/tests/data/demo_testset_layer.yml index 44102750..07514dd2 100644 --- a/tests/data/demo_testset_layer.yml +++ b/tests/data/demo_testset_layer.yml @@ -16,7 +16,7 @@ - test: name: get token api: get_token($user_agent, $device_sn, $os_platform, $app_version) - extractors: + extract: - token: content.token - test: diff --git a/tests/data/demo_testset_template_import_functions.yml b/tests/data/demo_testset_template_import_functions.yml index fc710cf8..9799d144 100644 --- a/tests/data/demo_testset_template_import_functions.yml +++ b/tests/data/demo_testset_template_import_functions.yml @@ -25,7 +25,7 @@ app_version: $app_version json: sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/tests/data/demo_testset_template_lambda_functions.yml b/tests/data/demo_testset_template_lambda_functions.yml index 7e450aa6..c45fb1b5 100644 --- a/tests/data/demo_testset_template_lambda_functions.yml +++ b/tests/data/demo_testset_template_lambda_functions.yml @@ -35,7 +35,7 @@ app_version: $app_version json: sign: ${get_sign_lambda($user_agent, $device_sn, $os_platform, $app_version)} - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/tests/data/demo_testset_variables.yml b/tests/data/demo_testset_variables.yml index 56e31fd6..116d2540 100644 --- a/tests/data/demo_testset_variables.yml +++ b/tests/data/demo_testset_variables.yml @@ -26,7 +26,7 @@ app_version: $app_version json: sign: $sign - extractors: + extract: - token: content.token validators: - {"check": "status_code", "comparator": "eq", "expected": 200} diff --git a/tests/test_runner.py b/tests/test_runner.py index 9996d25a..fcbf89d5 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -53,7 +53,7 @@ class TestRunner(ApiServerUnittest): "sign": "f1219719911caae89ccc301679857ebfda115ca2" } }, - "extractors": [ + "extract": [ {"token": "content.token"} ], "validators": [