update tests

This commit is contained in:
debugtalk
2017-09-28 14:29:23 +08:00
parent f8c4b1c10a
commit 9b0efc923e
3 changed files with 130 additions and 10 deletions

View File

@@ -24,3 +24,46 @@
json:
name: $user_name
password: $user_password
- api:
def: get_user($uid, $token)
request:
url: /api/users/$uid
method: GET
headers:
token: $token
- api:
def: update_user($uid, $user_name, $user_password, $token)
request:
url: /api/users/$uid
method: PUT
headers:
token: $token
json:
name: $user_name
password: $user_password
- api:
def: delete_user($uid, $token)
request:
url: /api/users/$uid
method: DELETE
headers:
token: $token
- api:
def: get_users($token)
request:
url: /api/users
method: GET
headers:
token: $token
- api:
def: reset_all($token)
request:
url: /api/reset-all
method: GET
headers:
token: $token

View File

@@ -1,5 +1,4 @@
import hashlib
import hmac
import json
from functools import wraps

View File

@@ -20,14 +20,18 @@
- token: content.token
- test:
name: create user which does not exist
variable_binds:
- user_name: "user1"
- user_password: "123456"
api: create_user(1000, $user_name, $user_password, $token)
name: reset all users
api: reset_all($token)
validators:
- {"check": "status_code", "comparator": "eq", "expected": 201}
- {"check": "content.success", "comparator": "eq", "expected": true}
- {"check": "status_code", "expected": 200}
- {"check": "content.success", "expected": true}
- test:
name: get user that does not exist
api: get_user(1000, $token)
validators:
- {"check": "status_code", "expected": 404}
- {"check": "content.success", "expected": false}
- test:
name: create user which does not exist
@@ -36,5 +40,79 @@
- user_password: "123456"
api: create_user(1000, $user_name, $user_password, $token)
validators:
- {"check": "status_code", "comparator": "eq", "expected": 500}
- {"check": "content.success", "comparator": "eq", "expected": false}
- {"check": "status_code", "expected": 201}
- {"check": "content.success", "expected": true}
- test:
name: get user that has been created
api: get_user(1000, $token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.success", "expected": true}
- {"check": "content.data.password", "expected": "123456"}
- test:
name: create user which exists
variable_binds:
- user_name: "user1"
- user_password: "123456"
api: create_user(1000, $user_name, $user_password, $token)
validators:
- {"check": "status_code", "expected": 500}
- {"check": "content.success", "expected": false}
- test:
name: update user which exists
variable_binds:
- user_name: "user1"
- user_password: "654321"
api: update_user(1000, $user_name, $user_password, $token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.success", "expected": true}
- test:
name: get user that has been created
api: get_user(1000, $token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.success", "expected": true}
- {"check": "content.data.password", "expected": "654321"}
- test:
name: get users
api: get_users($token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.count", "expected": 1}
- test:
name: delete user that exists
api: delete_user(1000, $token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.success", "expected": true}
- test:
name: get users
api: get_users($token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.count", "expected": 0}
- test:
name: create user which has been deleted
variable_binds:
- user_name: "user1"
- user_password: "123456"
api: create_user(1000, $user_name, $user_password, $token)
validators:
- {"check": "status_code", "expected": 201}
- {"check": "content.success", "expected": true}
- test:
name: get users
api: get_users($token)
validators:
- {"check": "status_code", "expected": 200}
- {"check": "content.count", "expected": 1}