add: tests
add: schedule endpoints
This commit is contained in:
parent
6d828fcffc
commit
b5a8523ae0
14 changed files with 468 additions and 42 deletions
17
tests/run_tests.sh
Executable file
17
tests/run_tests.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
mkdir ./testing_tmp
|
||||
cd ./testing_tmp
|
||||
|
||||
cp $1 ./core
|
||||
cp $2 ./core.ini
|
||||
|
||||
./core start >/dev/null 2>&1 &
|
||||
core_id=$!
|
||||
|
||||
sleep 2;
|
||||
|
||||
tavern-ci --tavern-beta-new-traceback ..
|
||||
kill $core_id
|
||||
cd ..
|
||||
rm -r ./testing_tmp
|
25
tests/test_get_all.tavern.yaml
Normal file
25
tests/test_get_all.tavern.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
test_name: Test basic get all requests
|
||||
|
||||
stages:
|
||||
- name: "[test_get_all] get all schedules"
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/schedules/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
||||
|
||||
- name: "[test_get_all] get all relays"
|
||||
skip: True
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/relays/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
||||
|
||||
- name: "[test_get_all] get all controllers"
|
||||
skip: True
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/controllers/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
50
tests/test_schedules_basic.tavern.yaml
Normal file
50
tests/test_schedules_basic.tavern.yaml
Normal file
|
@ -0,0 +1,50 @@
|
|||
test_name: Test basic requests
|
||||
|
||||
stages:
|
||||
- name: "[test_schedules_basic] Make sure we get any response"
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/schedules/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
||||
- name: "[test_schedules_basic] post schedule, expect it to be echoed back"
|
||||
request:
|
||||
method: POST
|
||||
url: "http://localhost:5000/api/v1/schedules/"
|
||||
json:
|
||||
name: "hello"
|
||||
periods:
|
||||
- start: '00:10'
|
||||
end: '00:20'
|
||||
- start: '00:30'
|
||||
end: '00:40'
|
||||
- start: '00:50'
|
||||
end: '01:00'
|
||||
response:
|
||||
status_code: 201
|
||||
body:
|
||||
name: "{tavern.request_vars.json.name}"
|
||||
save:
|
||||
body:
|
||||
returned_name: name
|
||||
returned_id: id
|
||||
- name: "[test_schedules_basic] get schedule, check name and some periods"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/{returned_id}"
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "{returned_name}"
|
||||
- name: "[test_schedules_basic] delete schedule"
|
||||
request:
|
||||
method: DELETE
|
||||
url: "http://localhost:5000/api/v1/schedules/{returned_id}"
|
||||
response:
|
||||
status_code: 200
|
||||
- name: "[test_schedules_basic] get deleted schedule, expect 404"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/{returned_id}"
|
||||
response:
|
||||
status_code: 404
|
66
tests/test_schedules_protected.tavern.yaml
Normal file
66
tests/test_schedules_protected.tavern.yaml
Normal file
|
@ -0,0 +1,66 @@
|
|||
test_name: Test basic requests
|
||||
|
||||
stages:
|
||||
- name: "[test_schedules_protected] delete protected off schedule; expect forbidden/fail"
|
||||
request:
|
||||
method: DELETE
|
||||
url: "http://localhost:5000/api/v1/schedules/off"
|
||||
response:
|
||||
status_code: 403
|
||||
- name: "[test_schedules_protected] get protected off schedule"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/off"
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "off"
|
||||
periods: []
|
||||
- name: "[test_schedules_protected] overwrite protected off schedule"
|
||||
request:
|
||||
method: PUT
|
||||
url: "http://localhost:5000/api/v1/schedules/off"
|
||||
json:
|
||||
name: "turned_off"
|
||||
periods:
|
||||
- start: "00:10"
|
||||
end: "00:20"
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "{tavern.request_vars.json.name}"
|
||||
periods: []
|
||||
|
||||
- name: "[test_schedules_protected] delete protected on schedule; expect forbidden/fail"
|
||||
request:
|
||||
method: DELETE
|
||||
url: "http://localhost:5000/api/v1/schedules/on"
|
||||
response:
|
||||
status_code: 403
|
||||
- name: get protected on schedule
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/on"
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "on"
|
||||
periods:
|
||||
- start: "00:00"
|
||||
end: "23:59"
|
||||
- name: "[test_schedules_protected] overwrite protected on schedule"
|
||||
request:
|
||||
method: PUT
|
||||
url: "http://localhost:5000/api/v1/schedules/on"
|
||||
json:
|
||||
name: "turned_on"
|
||||
periods:
|
||||
- start: "16:10"
|
||||
end: "17:20"
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "{tavern.request_vars.json.name}"
|
||||
periods:
|
||||
- start: "00:00"
|
||||
end: "23:59"
|
Loading…
Add table
Add a link
Reference in a new issue