add: foreign key support in database

add: more tests
fix: bad tag handling when finding 0 in column
This commit is contained in:
Tobias Reisinger 2020-05-28 02:12:39 +02:00
parent 7f3182ee96
commit 1475f605aa
14 changed files with 214 additions and 276 deletions

View file

@ -7,18 +7,12 @@ stages:
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
verify_response_with:
function: validate_controller:multiple
save:
json:
returned_id: "[0].id"
returned_relay_count: "[0].relay_count"
- name: "[controller_relays_basic] get controller relays, check length"
request:
@ -26,71 +20,11 @@ stages:
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
verify_response_with:
function: validate_relay:multiple
function: validate_relay:relay_count
extra_kwargs:
relay_count: !int "{returned_relay_count:d}"
- name: "[controller_relays_basic] get controller relays, check length"
request:
@ -98,42 +32,11 @@ stages:
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
verify_response_with:
function: validate_relay:single
function: validate_relay:check_controller_id
extra_kwargs:
name: "{returned_id}"
function: validate_relay:check_number
extra_kwargs:
number: 5

View file

@ -44,3 +44,56 @@ stages:
id: "{returned_id}"
name: "{returned_name}"
periods: "{returned_periods}"
- name: "[tags] discover controllers"
request:
method: POST
url: "http://localhost:5000/api/v1/controllers/discover/"
response:
status_code: 200
verify_response_with:
function: validate_controller:multiple
save:
json:
returned_id: "[0].id"
- name: "[tags] set relay tag"
request:
method: PUT
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/3"
json:
tags:
- "test_tag_1"
response:
status_code: 200
verify_response_with:
function: validate_relay:single
function: validate_relay:check_controller_id
extra_kwargs:
name: "{returned_id}"
function: validate_relay:check_number
extra_kwargs:
number: 3
function: validate_relay:check_tag
extra_kwargs:
tag: "{tavern.request_vars.json.tags[0]}"
save:
json:
returned_name: "name"
returned_number: "number"
returned_tag: "tags[0]"
- name: "[tags] get relay, check name and number"
request:
method: GET
url: "http://localhost:5000/api/v1/relays/tag/{returned_tag}"
response:
status_code: 200
verify_response_with:
function: validate_relay:multiple
function: validate_relay:find
extra_kwargs:
name: "{returned_name}"
number: !int "{returned_number:d}"
controller_id: "{returned_id}"
tag: "{returned_tag}"