mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 00:17:37 +08:00
move tests/data/debugtalk.py to tests/debugtalk.py
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
- config:
|
- config:
|
||||||
name: "create user testsets."
|
name: "create user testsets."
|
||||||
import_module_items:
|
import_module_items:
|
||||||
- tests.data.debugtalk
|
- tests.debugtalk
|
||||||
variables:
|
variables:
|
||||||
- user_agent: 'iOS/10.3'
|
- user_agent: 'iOS/10.3'
|
||||||
- device_sn: ${gen_random_string(15)}
|
- device_sn: ${gen_random_string(15)}
|
||||||
|
|||||||
@@ -56,3 +56,20 @@ def get_account():
|
|||||||
{"username": "user1", "password": "111111"},
|
{"username": "user1", "password": "111111"},
|
||||||
{"username": "user2", "password": "222222"}
|
{"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")
|
||||||
@@ -2,7 +2,11 @@
|
|||||||
- config:
|
- config:
|
||||||
name: "create user and check result."
|
name: "create user and check result."
|
||||||
def: create_and_check($uid, $token)
|
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:
|
output:
|
||||||
- token
|
- token
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
- device_sn: ${gen_random_string(15)}
|
- device_sn: ${gen_random_string(15)}
|
||||||
- os_platform: 'ios'
|
- os_platform: 'ios'
|
||||||
- app_version: '2.8.6'
|
- 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:
|
output:
|
||||||
- token
|
- token
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class VariableBindsUnittest(ApiServerUnittest):
|
|||||||
|
|
||||||
def test_import_module_items(self):
|
def test_import_module_items(self):
|
||||||
testcase1 = {
|
testcase1 = {
|
||||||
"import_module_items": ["tests.data.debugtalk"],
|
"import_module_items": ["tests.debugtalk"],
|
||||||
"variables": [
|
"variables": [
|
||||||
{"TOKEN": "debugtalk"},
|
{"TOKEN": "debugtalk"},
|
||||||
{"random": "${gen_random_string(5)}"},
|
{"random": "${gen_random_string(5)}"},
|
||||||
@@ -201,7 +201,7 @@ class VariableBindsUnittest(ApiServerUnittest):
|
|||||||
def test_get_parsed_request(self):
|
def test_get_parsed_request(self):
|
||||||
test_runner = runner.Runner()
|
test_runner = runner.Runner()
|
||||||
testcase = {
|
testcase = {
|
||||||
"import_module_items": ["tests.data.debugtalk"],
|
"import_module_items": ["tests.debugtalk"],
|
||||||
"variables": [
|
"variables": [
|
||||||
{"TOKEN": "debugtalk"},
|
{"TOKEN": "debugtalk"},
|
||||||
{"random": "${gen_random_string(5)}"},
|
{"random": "${gen_random_string(5)}"},
|
||||||
|
|||||||
+2
-2
@@ -300,7 +300,7 @@ class TestUtils(ApiServerUnittest):
|
|||||||
self.assertNotIn("is_py3", functions_dict)
|
self.assertNotIn("is_py3", functions_dict)
|
||||||
|
|
||||||
def test_get_imported_module_from_file(self):
|
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))
|
self.assertIn("gen_md5", dir(imported_module))
|
||||||
|
|
||||||
functions_dict = utils.filter_module(imported_module, "function")
|
functions_dict = utils.filter_module(imported_module, "function")
|
||||||
@@ -308,7 +308,7 @@ class TestUtils(ApiServerUnittest):
|
|||||||
self.assertNotIn("urllib", functions_dict)
|
self.assertNotIn("urllib", functions_dict)
|
||||||
|
|
||||||
with self.assertRaises(exception.FileNotFoundError):
|
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):
|
def test_search_conf_function(self):
|
||||||
gen_md5 = utils.search_conf_item("tests/data/demo_binds.yml", "function", "gen_md5")
|
gen_md5 = utils.search_conf_item("tests/data/demo_binds.yml", "function", "gen_md5")
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
name: smoketest
|
name: smoketest
|
||||||
variables:
|
variables:
|
||||||
- device_sn: ${gen_random_string(15)}
|
- 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:
|
- test:
|
||||||
name: setup and reset all.
|
name: setup and reset all.
|
||||||
|
|||||||
Reference in New Issue
Block a user