add: test

add: period filters
fix: invalid reads (lost invalid json debug output)
This commit is contained in:
Tobias Reisinger 2020-05-29 00:57:09 +02:00
parent f2a40ca330
commit 2d992cfe3c
6 changed files with 181 additions and 32 deletions
tests/tavern_tests

View file

@ -10,6 +10,24 @@ stages:
verify_response_with:
function: validate_schedule:multiple
- name: "[schedules_basic] post schedule with no periods, expect it to be echoed back"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "same as off"
periods: []
response:
status_code: 201
verify_response_with:
function: validate_schedule:single
function: validate_schedule:check_name
extra_kwargs:
name: "{tavern.request_vars.json.name}"
function: validate_schedule:check_periods
extra_kwargs:
periods: "{tavern.request_vars.json.periods}"
- name: "[schedules_basic] post schedule, expect it to be echoed back"
request:
method: POST
@ -67,3 +85,117 @@ stages:
url: "http://localhost:5000/api/v1/schedules/{returned_id}"
response:
status_code: 404
- name: "[schedules_basic] get schedule with bad id"
request:
method: GET
url: "http://localhost:5000/api/v1/schedules/this_id_is_invalid"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad body (no json)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
data: "<b>not json</b><i>but html</i>"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad body (no name)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
periods:
- start: "00:10"
end: "00:20"
- start: "00:30"
end: "00:40"
- start: "00:50"
end: "01:00"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad body (name as number)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: 42
periods:
- start: "00:10"
end: "00:20"
- start: "00:30"
end: "00:40"
- start: "00:50"
end: "01:00"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad period (no start)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "i am invalid"
periods:
- end: "00:20"
- start: "00:30"
end: "00:40"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad period (no end)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "i am invalid"
periods:
- start: "00:20"
- start: "00:30"
end: "00:40"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad period (invalid start)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "i am invalid"
periods:
- start: "hello"
end: "00:20"
- start: "00:30"
end: "00:40"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad period (invalid end)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "i am invalid"
periods:
- start: "12:10"
end: 1215
- start: "00:30"
end: "00:40"
response:
status_code: 400
- name: "[schedules_basic] post schedule with bad period (invalid end 2)"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "i am invalid"
periods:
- start: "12:10"
end: "25:90"
- start: "00:30"
end: "00:40"
response:
status_code: 400