move tests/data/debugtalk.py to tests/debugtalk.py

This commit is contained in:
httprunner
2018-05-07 15:19:14 +08:00
parent 1c7c65523e
commit 901eaab220
8 changed files with 37 additions and 8 deletions

View File

View File

@@ -1,7 +1,7 @@
- config:
name: "create user testsets."
import_module_items:
- tests.data.debugtalk
- tests.debugtalk
variables:
- user_agent: 'iOS/10.3'
- device_sn: ${gen_random_string(15)}

View File

@@ -56,3 +56,20 @@ def get_account():
{"username": "user1", "password": "111111"},
{"username": "user2", "password": "222222"}
]
SECRET_KEY = "DebugTalk"
def gen_random_string(str_len):
random_char_list = []
for _ in range(str_len):
random_char = random.choice(string.ascii_letters + string.digits)
random_char_list.append(random_char)
random_string = ''.join(random_char_list)
return random_string
def setup_hook_add_kwargs(method, url, kwargs):
kwargs["key"] = "value"
def setup_hook_remove_kwargs(method, url, kwargs):
kwargs.pop("key")

View File

@@ -2,7 +2,11 @@
- config:
name: "create user and check result."
def: create_and_check($uid, $token)
request: $default_request
request:
"base_url": "http://127.0.0.1:5000"
"headers":
"Content-Type": "application/json"
"device_sn": "$device_sn"
output:
- token

View File

@@ -6,7 +6,11 @@
- device_sn: ${gen_random_string(15)}
- os_platform: 'ios'
- app_version: '2.8.6'
request: $default_request
request:
"base_url": "http://127.0.0.1:5000"
"headers":
"Content-Type": "application/json"
"device_sn": "$device_sn"
output:
- token

View File

@@ -163,7 +163,7 @@ class VariableBindsUnittest(ApiServerUnittest):
def test_import_module_items(self):
testcase1 = {
"import_module_items": ["tests.data.debugtalk"],
"import_module_items": ["tests.debugtalk"],
"variables": [
{"TOKEN": "debugtalk"},
{"random": "${gen_random_string(5)}"},
@@ -201,7 +201,7 @@ class VariableBindsUnittest(ApiServerUnittest):
def test_get_parsed_request(self):
test_runner = runner.Runner()
testcase = {
"import_module_items": ["tests.data.debugtalk"],
"import_module_items": ["tests.debugtalk"],
"variables": [
{"TOKEN": "debugtalk"},
{"random": "${gen_random_string(5)}"},

View File

@@ -300,7 +300,7 @@ class TestUtils(ApiServerUnittest):
self.assertNotIn("is_py3", functions_dict)
def test_get_imported_module_from_file(self):
imported_module = utils.get_imported_module_from_file("tests/data/debugtalk.py")
imported_module = utils.get_imported_module_from_file("tests/debugtalk.py")
self.assertIn("gen_md5", dir(imported_module))
functions_dict = utils.filter_module(imported_module, "function")
@@ -308,7 +308,7 @@ class TestUtils(ApiServerUnittest):
self.assertNotIn("urllib", functions_dict)
with self.assertRaises(exception.FileNotFoundError):
utils.get_imported_module_from_file("tests/data/debugtalk2.py")
utils.get_imported_module_from_file("tests/debugtalk2.py")
def test_search_conf_function(self):
gen_md5 = utils.search_conf_item("tests/data/demo_binds.yml", "function", "gen_md5")

View File

@@ -2,7 +2,11 @@
name: smoketest
variables:
- device_sn: ${gen_random_string(15)}
request: $default_request
request:
"base_url": "http://127.0.0.1:5000"
"headers":
"Content-Type": "application/json"
"device_sn": "$device_sn"
- test:
name: setup and reset all.