fix unittest c4805ccb98e909b9586eea3e30c15b40fb0bbf8a

This commit is contained in:
debugtalk
2018-12-17 23:08:35 +08:00
parent a0121b9007
commit 2640720332
4 changed files with 20 additions and 20 deletions

View File

@@ -17,7 +17,7 @@
- test:
name: get token with $user_agent and $username
api: get_token
api: api/get_token.yml
extract:
- token: content.token
validate:

View File

@@ -11,7 +11,7 @@
- test:
name: get token with $user_agent, $app_version
api: get_token
api: api/get_token.yml
extract:
- token: content.token
validate:
@@ -21,7 +21,7 @@
- test:
name: reset all users
api: reset_all
api: api/reset_all.yml
variables:
token: $token
validate:
@@ -30,7 +30,7 @@
- test:
name: get user that does not exist
api: get_user
api: api/get_user.yml
variables:
uid: 1000
token: $token
@@ -45,14 +45,14 @@
user_name: "user1"
user_password: "123456"
token: $token
api: create_user
api: api/create_user.yml
validate:
- {"check": "status_code", "expect": 201}
- {"check": "content.success", "expect": true}
- test:
name: get user that has been created
api: get_user
api: api/get_user.yml
variables:
uid: 1000
token: $token
@@ -68,7 +68,7 @@
user_name: "user1"
user_password: "123456"
token: $token
api: create_user
api: api/create_user.yml
validate:
- {"check": "status_code", "expect": 500}
- {"check": "content.success", "expect": false}
@@ -80,14 +80,14 @@
user_name: "user1"
user_password: "654321"
token: $token
api: update_user
api: api/update_user.yml
validate:
- {"check": "status_code", "expect": 200}
- {"check": "content.success", "expect": true}
- test:
name: get user that has been updated
api: get_user
api: api/get_user.yml
variables:
uid: 1000
token: $token
@@ -98,7 +98,7 @@
- test:
name: get users
api: get_users
api: api/get_users.yml
variables:
token: $token
validate:
@@ -107,7 +107,7 @@
- test:
name: delete user that exists
api: delete_user
api: api/delete_user.yml
variables:
uid: 1000
token: $token
@@ -117,7 +117,7 @@
- test:
name: get users
api: get_users
api: api/get_users.yml
variables:
token: $token
validate:
@@ -131,14 +131,14 @@
user_name: "user1"
user_password: "123456"
token: $token
api: create_user
api: api/create_user.yml
validate:
- {"check": "status_code", "expect": 201}
- {"check": "content.success", "expect": true}
- test:
name: get users
api: get_users
api: api/get_users.yml
variables:
token: $token
validate:

View File

@@ -438,12 +438,12 @@ class TestSuiteLoader(unittest.TestCase):
def test_load_api_folder(self):
path = os.path.join(os.getcwd(), "tests", "api")
api_definition_mapping = loader.load_api_folder(path)
self.assertIn("get_token", api_definition_mapping)
self.assertIn("request", api_definition_mapping["get_token"])
api_path = os.path.join(os.getcwd(), "tests", "api", "get_token.yml")
self.assertIn(api_path, api_definition_mapping)
api_file_path = os.path.join(os.getcwd(), "tests", "api", "get_token.yml")
self.assertIn(api_file_path, api_definition_mapping)
self.assertIn("request", api_definition_mapping[api_file_path])
def test_load_project_tests(self):
loader.load_project_tests(os.path.join(os.getcwd(), "tests"))
self.assertIn("get_token", self.tests_def_mapping["api"])
api_file_path = os.path.join(os.getcwd(), "tests", "api", "get_token.yml")
self.assertIn(api_file_path, self.tests_def_mapping["api"])
self.assertEqual(self.project_mapping["env"]["PROJECT_KEY"], "ABCDEFGH")

View File

@@ -628,7 +628,7 @@ class TestParser(unittest.TestCase):
raw_testinfo = {
"name": "get token",
"base_url": "https://debugtalk.com",
"api": "get_token",
"api": "api/get_token.yml",
}
api_def_dict = loader.load_teststep(raw_testinfo)
test_block = {