mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 20:38:44 +08:00
change variable marker and function marker:
1, variable marker: ${var} => $var;
2, function marker: {'func': 'gen_random_string', 'args': [5]} => ${gen_random_string(5).
This commit is contained in:
@@ -7,15 +7,15 @@ register_variables:
|
||||
register_template_variables:
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
- token: ${TOKEN}
|
||||
- token: $TOKEN
|
||||
|
||||
bind_lambda_functions:
|
||||
function_binds:
|
||||
add_one: "lambda x: x + 1"
|
||||
add_two_nums: "lambda x, y: x + y"
|
||||
variable_binds:
|
||||
- add1: {"func": "add_one", "args": [2]}
|
||||
- sum2nums: {"func": "add_two_nums", "args": [2, 3]}
|
||||
- add1: ${add_one(2)}
|
||||
- sum2nums: ${add_two_nums(2, 3)}
|
||||
|
||||
bind_lambda_functions_with_import:
|
||||
requires:
|
||||
@@ -27,9 +27,9 @@ bind_lambda_functions_with_import:
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- random: ${gen_random_string(5)}
|
||||
- data: "{'name': 'user', 'password': '123456'}"
|
||||
- authorization: {"func": "gen_md5", "args": ["${TOKEN}", "${data}", "${random}"]}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
|
||||
bind_module_functions:
|
||||
function_binds:
|
||||
@@ -37,6 +37,6 @@ bind_module_functions:
|
||||
- test.data.custom_functions
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- random: ${gen_random_string(5)}
|
||||
- data: "{'name': 'user', 'password': '123456'}"
|
||||
- authorization: {"func": "gen_md5", "args": ["${TOKEN}", "${data}", "${random}"]}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
- test.data.custom_functions
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- json: {"name": "user", "password": "123456"}
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- authorization: {"func": "gen_md5", "args": ["${TOKEN}", "${json}", "${random}"]}
|
||||
- json: {}
|
||||
- random: ${gen_random_string(5)}
|
||||
- authorization: ${gen_md5($TOKEN, $json, $random)}
|
||||
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
@@ -17,9 +17,9 @@
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
json: "${json}"
|
||||
authorization: $authorization
|
||||
random: $random
|
||||
json: $json
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": true}
|
||||
@@ -33,9 +33,9 @@
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
json: "${json}"
|
||||
authorization: $authorization
|
||||
random: $random
|
||||
json: $json
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": false}
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- random: ${gen_random_string(5)}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["${TOKEN}", "${data}", "${random}"]}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
authorization: $authorization
|
||||
random: $random
|
||||
data: $data
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": true}
|
||||
@@ -36,17 +36,17 @@
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- random: ${gen_random_string(5)}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["${TOKEN}", "${data}", "${random}"]}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
authorization: $authorization
|
||||
random: $random
|
||||
data: $data
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": false}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- data: ""
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- authorization: {"func": "gen_md5", "args": ["${TOKEN}", "${data}", "${random}"]}
|
||||
- random: ${gen_random_string(5)}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
request:
|
||||
base_url: http://127.0.0.1:5000
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
authorization: $authorization
|
||||
random: $random
|
||||
data: $data
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": true}
|
||||
@@ -41,9 +41,9 @@
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
authorization: $authorization
|
||||
random: $random
|
||||
data: $data
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": false}
|
||||
|
||||
Reference in New Issue
Block a user