add: better tavern usage (python validator for schedules)
This commit is contained in:
parent
251389a454
commit
7f3182ee96
13 changed files with 433 additions and 187 deletions
139
tests/tavern_tests/controller_relays_basic.tavern.yaml
Normal file
139
tests/tavern_tests/controller_relays_basic.tavern.yaml
Normal file
|
@ -0,0 +1,139 @@
|
|||
test_name: Test basic controller relays functions
|
||||
|
||||
stages:
|
||||
- name: "[controller_relays_basic] discover controllers"
|
||||
request:
|
||||
method: POST
|
||||
url: "http://localhost:5000/api/v1/controllers/discover/"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
relay_count: !anyint
|
||||
relays: !anystr
|
||||
active: !anybool
|
||||
port: !anyint
|
||||
ip: !anystr
|
||||
relays: !anylist
|
||||
save:
|
||||
json:
|
||||
returned_id: "[0].id"
|
||||
|
||||
- name: "[controller_relays_basic] get controller relays, check length"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
- name: !anystr
|
||||
number: 0
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule:
|
||||
id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 1
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 2
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 3
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 4
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 5
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 6
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 7
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 8
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
- name: !anystr
|
||||
number: 9
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule: !anydict
|
||||
schedules: !anylist
|
||||
tags: !anylist
|
||||
|
||||
- name: "[controller_relays_basic] get controller relays, check length"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/5"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
name: !anystr
|
||||
number: 5
|
||||
controller_id: "{returned_id}"
|
||||
active_schedule:
|
||||
id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
schedules:
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
periods: !anylist
|
||||
tags: !anylist
|
||||
tags: !anylist
|
105
tests/tavern_tests/controllers_basic.tavern.yaml
Normal file
105
tests/tavern_tests/controllers_basic.tavern.yaml
Normal file
|
@ -0,0 +1,105 @@
|
|||
test_name: Test basic controller functions
|
||||
|
||||
stages:
|
||||
- name: "[controllers_basic] discover controllers"
|
||||
request:
|
||||
method: POST
|
||||
url: "http://localhost:5000/api/v1/controllers/discover/"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
- id: !anystr
|
||||
name: !anystr
|
||||
relay_count: !anyint
|
||||
relays: !anystr
|
||||
active: !anybool
|
||||
port: !anyint
|
||||
ip: !anystr
|
||||
relays: !anylist
|
||||
save:
|
||||
json:
|
||||
returned_name: "[0].name"
|
||||
returned_id: "[0].id"
|
||||
|
||||
- name: "[controllers_basic] get controller, check name"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
name: "{returned_name}"
|
||||
id: "{returned_id}"
|
||||
relay_count: !anyint
|
||||
relays: !anystr
|
||||
active: !anybool
|
||||
port: !anyint
|
||||
ip: !anystr
|
||||
relays: !anylist
|
||||
|
||||
- name: "[controllers_basic] get controller, check name"
|
||||
request:
|
||||
method: PUT
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}"
|
||||
json:
|
||||
name: "renamed_controller"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
name: "{tavern.request_vars.json.name}"
|
||||
id: "{returned_id}"
|
||||
relay_count: !anyint
|
||||
relays: !anystr
|
||||
active: true
|
||||
port: !anyint
|
||||
ip: !anystr
|
||||
relays: !anylist
|
||||
save:
|
||||
json:
|
||||
changed_name: "name"
|
||||
|
||||
- name: "[controllers_basic] delete controller"
|
||||
request:
|
||||
method: DELETE
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}"
|
||||
response:
|
||||
status_code: 200
|
||||
|
||||
- name: "[controllers_basic] get controller, expect 404"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}"
|
||||
response:
|
||||
status_code: 404
|
||||
|
||||
- name: "[controllers_basic] discover controllers again"
|
||||
request:
|
||||
method: POST
|
||||
url: "http://localhost:5000/api/v1/controllers/discover/"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
- id: "{returned_id}"
|
||||
name: "{changed_name}"
|
||||
relay_count: !anyint
|
||||
relays: !anystr
|
||||
active: true
|
||||
port: !anyint
|
||||
ip: !anystr
|
||||
relays: !anylist
|
||||
|
||||
- name: "[controllers_basic] get controller again, check name"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}"
|
||||
response:
|
||||
status_code: 200
|
||||
json:
|
||||
id: "{returned_id}"
|
||||
name: "{changed_name}"
|
||||
relay_count: !anyint
|
||||
relays: !anystr
|
||||
active: true
|
||||
port: !anyint
|
||||
ip: !anystr
|
||||
relays: !anylist
|
23
tests/tavern_tests/get_all.tavern.yaml
Normal file
23
tests/tavern_tests/get_all.tavern.yaml
Normal file
|
@ -0,0 +1,23 @@
|
|||
test_name: "[get_all] Test basic get all requests"
|
||||
|
||||
stages:
|
||||
- name: "[get_all] get all schedules"
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/schedules/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
||||
|
||||
- name: "[get_all] get all relays"
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/relays/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
||||
|
||||
- name: "[get_all] get all controllers"
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/controllers/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
69
tests/tavern_tests/schedules_basic.tavern.yaml
Normal file
69
tests/tavern_tests/schedules_basic.tavern.yaml
Normal file
|
@ -0,0 +1,69 @@
|
|||
test_name: Test basic schedule requests
|
||||
|
||||
stages:
|
||||
- name: "[schedules_basic] Make sure we get any response"
|
||||
request:
|
||||
url: "http://localhost:5000/api/v1/schedules/"
|
||||
method: GET
|
||||
response:
|
||||
status_code: 200
|
||||
verify_response_with:
|
||||
function: validate_schedule:multiple
|
||||
|
||||
- name: "[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
|
||||
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}"
|
||||
save:
|
||||
json:
|
||||
returned_name: "name"
|
||||
returned_id: "id"
|
||||
returned_periods: "periods"
|
||||
|
||||
- name: "[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
|
||||
verify_response_with:
|
||||
function: validate_schedule:single
|
||||
function: validate_schedule:check_name
|
||||
extra_kwargs:
|
||||
name: "{returned_name}"
|
||||
function: validate_schedule:check_periods
|
||||
extra_kwargs:
|
||||
periods: "{returned_periods}"
|
||||
|
||||
- name: "[schedules_basic] delete schedule"
|
||||
request:
|
||||
method: DELETE
|
||||
url: "http://localhost:5000/api/v1/schedules/{returned_id}"
|
||||
response:
|
||||
status_code: 200
|
||||
|
||||
- name: "[schedules_basic] get deleted schedule, expect 404"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/{returned_id}"
|
||||
response:
|
||||
status_code: 404
|
72
tests/tavern_tests/schedules_protected.tavern.yaml
Normal file
72
tests/tavern_tests/schedules_protected.tavern.yaml
Normal file
|
@ -0,0 +1,72 @@
|
|||
test_name: Test protected schedules requests
|
||||
|
||||
stages:
|
||||
- name: "[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: "[schedules_protected] get protected off schedule"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/off"
|
||||
response:
|
||||
status_code: 200
|
||||
verify_response_with:
|
||||
function: validate_schedule:single
|
||||
function: validate_schedule:compare_off
|
||||
|
||||
- name: "[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
|
||||
verify_response_with:
|
||||
function: validate_schedule:single
|
||||
function: validate_schedule:compare_off
|
||||
function: validate_schedule:check_name
|
||||
extra_kwargs:
|
||||
name: "{tavern.request_vars.json.name}"
|
||||
|
||||
- name: "[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
|
||||
verify_response_with:
|
||||
function: validate_schedule:single
|
||||
function: validate_schedule:compare_on
|
||||
|
||||
- name: "[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
|
||||
verify_response_with:
|
||||
function: validate_schedule:single
|
||||
function: validate_schedule:compare_on
|
||||
function: validate_schedule:check_name
|
||||
extra_kwargs:
|
||||
name: "{tavern.request_vars.json.name}"
|
46
tests/tavern_tests/tags.tavern.yaml
Normal file
46
tests/tavern_tests/tags.tavern.yaml
Normal file
|
@ -0,0 +1,46 @@
|
|||
test_name: "[tags] Test tagging of schedules and relays"
|
||||
|
||||
stages:
|
||||
- name: "[tags] post schedule, expect it to be echoed back by tag"
|
||||
request:
|
||||
method: POST
|
||||
url: "http://localhost:5000/api/v1/schedules/"
|
||||
json:
|
||||
name: "test tagging schedule"
|
||||
periods:
|
||||
- start: "00:50"
|
||||
end: "01:00"
|
||||
tags:
|
||||
- "test_tag_1"
|
||||
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}"
|
||||
function: validate_schedule:check_tag
|
||||
extra_kwargs:
|
||||
tag: "{tavern.request_vars.json.tags[0]}"
|
||||
save:
|
||||
json:
|
||||
returned_name: "name"
|
||||
returned_id: "id"
|
||||
returned_periods: "periods"
|
||||
|
||||
- name: "[tags] get schedule, check name and some periods"
|
||||
request:
|
||||
method: GET
|
||||
url: "http://localhost:5000/api/v1/schedules/tag/test_tag_1"
|
||||
response:
|
||||
status_code: 200
|
||||
verify_response_with:
|
||||
function: validate_schedule:multiple
|
||||
function: validate_schedule:find
|
||||
extra_kwargs:
|
||||
id: "{returned_id}"
|
||||
name: "{returned_name}"
|
||||
periods: "{returned_periods}"
|
Loading…
Add table
Add a link
Reference in a new issue