mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 23:30:09 +08:00
save api in individual file: each file is corresponding to one api definition
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
id: get_token
|
||||
name: get token
|
||||
variables:
|
||||
|
||||
user_agent: XXX
|
||||
device_sn: API_XXX
|
||||
os_platform: XXX
|
||||
|
||||
17
tests/api/create_user.yml
Normal file
17
tests/api/create_user.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
variables:
|
||||
user_name: user0
|
||||
user_password: "000000"
|
||||
uid: 9000
|
||||
token: XXX
|
||||
request:
|
||||
url: /api/users/$uid
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
json:
|
||||
name: $user_name
|
||||
password: $user_password
|
||||
validate:
|
||||
- eq: ["status_code", 201]
|
||||
12
tests/api/delete_user.yml
Normal file
12
tests/api/delete_user.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
variables:
|
||||
uid: 9000
|
||||
token: XXX
|
||||
request:
|
||||
url: /api/users/$uid
|
||||
method: DELETE
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
16
tests/api/get_headers.yml
Normal file
16
tests/api/get_headers.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
variables:
|
||||
n_secs: 1
|
||||
request:
|
||||
url: /headers
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
method: GET
|
||||
setup_hooks:
|
||||
- ${setup_hook_add_kwargs($request)}
|
||||
- ${setup_hook_remove_kwargs($request)}
|
||||
teardown_hooks:
|
||||
- ${teardown_hook_sleep_N_secs($response, $n_secs)}
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- contained_by: [content.headers.Host, "${get_httpbin_server()}"]
|
||||
22
tests/api/get_token.yml
Normal file
22
tests/api/get_token.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
name: get token
|
||||
variables:
|
||||
user_agent: XXX
|
||||
device_sn: API_XXX
|
||||
os_platform: XXX
|
||||
app_version: XXX
|
||||
request:
|
||||
url: /api/get-token
|
||||
method: POST
|
||||
headers:
|
||||
user_agent: $user_agent
|
||||
device_sn: $device_sn
|
||||
os_platform: $os_platform
|
||||
app_version: $app_version
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
json:
|
||||
sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)}
|
||||
validate:
|
||||
- eq: ["status_code", 0]
|
||||
- len_eq: ["content.token", 12]
|
||||
- contains: [{"a": 1, "b": 2}, "a"]
|
||||
12
tests/api/get_user.yml
Normal file
12
tests/api/get_user.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
variables:
|
||||
uid: 9000
|
||||
token: XXX
|
||||
request:
|
||||
url: /api/users/$uid
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
11
tests/api/get_users.yml
Normal file
11
tests/api/get_users.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
variables:
|
||||
token: XXX
|
||||
request:
|
||||
url: /api/users
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
12
tests/api/reset_all.yml
Normal file
12
tests/api/reset_all.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
variables:
|
||||
token: XXX
|
||||
request:
|
||||
url: /api/reset-all
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- eq: ["content.success", true]
|
||||
17
tests/api/update_user.yml
Normal file
17
tests/api/update_user.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
variables:
|
||||
user_name: user0
|
||||
user_password: "000000"
|
||||
uid: 9000
|
||||
token: XXX
|
||||
request:
|
||||
url: /api/users/$uid
|
||||
method: PUT
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
json:
|
||||
name: $user_name
|
||||
password: $user_password
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
Reference in New Issue
Block a user