mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-17 15:07:38 +08:00
rename keyword: variable_binds => variables
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
bind_variables:
|
||||
variable_binds:
|
||||
variables:
|
||||
- TOKEN: "debugtalk"
|
||||
- token: $TOKEN
|
||||
|
||||
@@ -7,7 +7,7 @@ bind_lambda_functions:
|
||||
function_binds:
|
||||
add_one: "lambda x: x + 1"
|
||||
add_two_nums: "lambda x, y: x + y"
|
||||
variable_binds:
|
||||
variables:
|
||||
- add1: ${add_one(2)}
|
||||
- sum2nums: ${add_two_nums(2, 3)}
|
||||
|
||||
@@ -19,7 +19,7 @@ bind_lambda_functions_with_import:
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
variables:
|
||||
- TOKEN: debugtalk
|
||||
- random: ${gen_random_string(5)}
|
||||
- data: "{'name': 'user', 'password': '123456'}"
|
||||
@@ -29,7 +29,7 @@ bind_module_functions:
|
||||
function_binds:
|
||||
import_module_items:
|
||||
- tests.data.debugtalk
|
||||
variable_binds:
|
||||
variables:
|
||||
- TOKEN: debugtalk
|
||||
- random: ${gen_random_string(5)}
|
||||
- data: "{'name': 'user', 'password': '123456'}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- config:
|
||||
name: "user management testset."
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_agent: 'iOS/10.3'
|
||||
- device_sn: ${gen_random_string(15)}
|
||||
- os_platform: 'ios'
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
api: create_user(1000, $user_name, $user_password, $token)
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
- test:
|
||||
name: create user which exists
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
api: create_user(1000, $user_name, $user_password, $token)
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
- test:
|
||||
name: update user which exists
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "654321"
|
||||
api: update_user(1000, $user_name, $user_password, $token)
|
||||
@@ -102,7 +102,7 @@
|
||||
|
||||
- test:
|
||||
name: create user which has been deleted
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
api: create_user(1000, $user_name, $user_password, $token)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: "create user testsets."
|
||||
import_module_items:
|
||||
- tests.data.debugtalk
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_agent: 'iOS/10.3'
|
||||
- device_sn: ${gen_random_string(15)}
|
||||
- os_platform: 'ios'
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
request:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
'DebugTalk'.encode('ascii'),
|
||||
''.join(args).encode('ascii'),
|
||||
hashlib.sha1).hexdigest()"
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_agent: 'iOS/10.3'
|
||||
- device_sn: ${gen_random_string_lambda(15)}
|
||||
- os_platform: 'ios'
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
request:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- config:
|
||||
name: "create user testsets."
|
||||
variable_binds:
|
||||
variables:
|
||||
- device_sn: 'HZfFBh6tU59EdXJ'
|
||||
request:
|
||||
base_url: $BASE_URL
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- test:
|
||||
name: get token
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_agent: 'iOS/10.3'
|
||||
- os_platform: 'ios'
|
||||
- app_version: '2.8.6'
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
variable_binds:
|
||||
variables:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
request:
|
||||
|
||||
@@ -18,11 +18,11 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
self.assertIn("get_timestamp", self.context.testset_functions_config)
|
||||
self.assertIn("gen_random_string", self.context.testset_functions_config)
|
||||
|
||||
variable_binds = [
|
||||
variables = [
|
||||
{"random": "${gen_random_string(5)}"},
|
||||
{"timestamp10": "${get_timestamp(10)}"}
|
||||
]
|
||||
self.context.bind_variables(variable_binds)
|
||||
self.context.bind_variables(variables)
|
||||
context_variables = self.context.get_testcase_variables_mapping()
|
||||
|
||||
self.assertEqual(len(context_variables["random"]), 5)
|
||||
@@ -31,7 +31,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
def test_context_bind_testset_variables(self):
|
||||
# testcase in JSON format
|
||||
testcase1 = {
|
||||
"variable_binds": [
|
||||
"variables": [
|
||||
{"GLOBAL_TOKEN": "debugtalk"},
|
||||
{"token": "$GLOBAL_TOKEN"}
|
||||
]
|
||||
@@ -40,8 +40,8 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
testcase2 = self.testcases["bind_variables"]
|
||||
|
||||
for testcase in [testcase1, testcase2]:
|
||||
variable_binds = testcase['variable_binds']
|
||||
self.context.bind_variables(variable_binds, level="testset")
|
||||
variables = testcase['variables']
|
||||
self.context.bind_variables(variables, level="testset")
|
||||
|
||||
testset_variables = self.context.testset_shared_variables_mapping
|
||||
testcase_variables = self.context.get_testcase_variables_mapping()
|
||||
@@ -54,7 +54,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
|
||||
def test_context_bind_testcase_variables(self):
|
||||
testcase1 = {
|
||||
"variable_binds": [
|
||||
"variables": [
|
||||
{"GLOBAL_TOKEN": "debugtalk"},
|
||||
{"token": "$GLOBAL_TOKEN"}
|
||||
]
|
||||
@@ -62,8 +62,8 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
testcase2 = self.testcases["bind_variables"]
|
||||
|
||||
for testcase in [testcase1, testcase2]:
|
||||
variable_binds = testcase['variable_binds']
|
||||
self.context.bind_variables(variable_binds)
|
||||
variables = testcase['variables']
|
||||
self.context.bind_variables(variables)
|
||||
|
||||
testset_variables = self.context.testset_shared_variables_mapping
|
||||
testcase_variables = self.context.get_testcase_variables_mapping()
|
||||
@@ -80,7 +80,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
"add_one": lambda x: x + 1,
|
||||
"add_two_nums": lambda x, y: x + y
|
||||
},
|
||||
"variable_binds": [
|
||||
"variables": [
|
||||
{"add1": "${add_one(2)}"},
|
||||
{"sum2nums": "${add_two_nums(2,3)}"}
|
||||
]
|
||||
@@ -91,8 +91,8 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
function_binds = testcase.get('function_binds', {})
|
||||
self.context.bind_functions(function_binds)
|
||||
|
||||
variable_binds = testcase['variable_binds']
|
||||
self.context.bind_variables(variable_binds)
|
||||
variables = testcase['variables']
|
||||
self.context.bind_variables(variables)
|
||||
|
||||
context_variables = self.context.get_testcase_variables_mapping()
|
||||
self.assertIn("add1", context_variables)
|
||||
@@ -107,7 +107,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
"gen_random_string": "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))",
|
||||
"gen_md5": "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
},
|
||||
"variable_binds": [
|
||||
"variables": [
|
||||
{"TOKEN": "debugtalk"},
|
||||
{"random": "${gen_random_string(5)}"},
|
||||
{"data": '{"name": "user", "password": "123456"}'},
|
||||
@@ -123,8 +123,8 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
function_binds = testcase.get('function_binds', {})
|
||||
self.context.bind_functions(function_binds)
|
||||
|
||||
variable_binds = testcase['variable_binds']
|
||||
self.context.bind_variables(variable_binds)
|
||||
variables = testcase['variables']
|
||||
self.context.bind_variables(variables)
|
||||
context_variables = self.context.get_testcase_variables_mapping()
|
||||
|
||||
self.assertIn("TOKEN", context_variables)
|
||||
@@ -144,7 +144,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
def test_import_module_items(self):
|
||||
testcase1 = {
|
||||
"import_module_items": ["tests.data.debugtalk"],
|
||||
"variable_binds": [
|
||||
"variables": [
|
||||
{"TOKEN": "debugtalk"},
|
||||
{"random": "${gen_random_string(5)}"},
|
||||
{"data": '{"name": "user", "password": "123456"}'},
|
||||
@@ -157,8 +157,8 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
module_items = testcase.get('import_module_items', [])
|
||||
self.context.import_module_items(module_items)
|
||||
|
||||
variable_binds = testcase['variable_binds']
|
||||
self.context.bind_variables(variable_binds)
|
||||
variables = testcase['variables']
|
||||
self.context.bind_variables(variables)
|
||||
context_variables = self.context.get_testcase_variables_mapping()
|
||||
|
||||
self.assertIn("TOKEN", context_variables)
|
||||
@@ -182,7 +182,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
test_runner = runner.Runner()
|
||||
testcase = {
|
||||
"import_module_items": ["tests.data.debugtalk"],
|
||||
"variable_binds": [
|
||||
"variables": [
|
||||
{"TOKEN": "debugtalk"},
|
||||
{"random": "${gen_random_string(5)}"},
|
||||
{"data": '{"name": "user", "password": "123456"}'},
|
||||
@@ -206,7 +206,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
self.assertIn("random", parsed_request["headers"])
|
||||
self.assertEqual(len(parsed_request["headers"]["random"]), 5)
|
||||
self.assertIn("data", parsed_request)
|
||||
self.assertEqual(parsed_request["data"], testcase["variable_binds"][2]["data"])
|
||||
self.assertEqual(parsed_request["data"], testcase["variables"][2]["data"])
|
||||
self.assertEqual(parsed_request["headers"]["SECRET_KEY"], "DebugTalk")
|
||||
|
||||
def test_exec_content_functions(self):
|
||||
|
||||
@@ -55,7 +55,7 @@ class TestcaseParserUnittest(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_eval_content_variables(self):
|
||||
variable_binds = {
|
||||
variables = {
|
||||
"var_1": "abc",
|
||||
"var_2": "def",
|
||||
"var_3": 123,
|
||||
@@ -63,7 +63,7 @@ class TestcaseParserUnittest(unittest.TestCase):
|
||||
"var_5": True,
|
||||
"var_6": None
|
||||
}
|
||||
testcase_parser = testcase.TestcaseParser(variables_binds=variable_binds)
|
||||
testcase_parser = testcase.TestcaseParser(variables_binds=variables)
|
||||
self.assertEqual(
|
||||
testcase_parser.eval_content_variables("$var_1"),
|
||||
"abc"
|
||||
@@ -417,7 +417,7 @@ class TestcaseParserUnittest(unittest.TestCase):
|
||||
path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_layer.yml')
|
||||
testsets_list = testcase.load_testcases_by_path(path)
|
||||
self.assertIn("variable_binds", testsets_list[0]["config"])
|
||||
self.assertIn("variables", testsets_list[0]["config"])
|
||||
self.assertIn("request", testsets_list[0]["config"])
|
||||
self.assertIn("request", testsets_list[0]["testcases"][0])
|
||||
self.assertIn("url", testsets_list[0]["testcases"][0]["request"])
|
||||
|
||||
Reference in New Issue
Block a user