From 7f3182ee96da0725bb794fece7dffd7ef245921b Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Thu, 28 May 2020 00:06:03 +0200 Subject: [PATCH] add: better tavern usage (python validator for schedules) --- tests/run_tests.sh | 3 +- .../controller_relays_basic.tavern.yaml | 139 ++++++++++++++++++ .../controllers_basic.tavern.yaml} | 14 +- .../get_all.tavern.yaml} | 0 .../tavern_tests/schedules_basic.tavern.yaml | 69 +++++++++ .../schedules_protected.tavern.yaml | 72 +++++++++ tests/tavern_tests/tags.tavern.yaml | 46 ++++++ .../validate_schedule.cpython-38.pyc | Bin 0 -> 3698 bytes tests/tavern_utils/validate_relay.py | 2 + tests/tavern_utils/validate_schedule.py | 96 ++++++++++++ tests/test_schedules_basic.tavern.yaml | 58 -------- tests/test_schedules_protected.tavern.yaml | 78 ---------- tests/test_tags.tavern.yaml | 43 ------ 13 files changed, 433 insertions(+), 187 deletions(-) create mode 100644 tests/tavern_tests/controller_relays_basic.tavern.yaml rename tests/{test_controllers_basic.tavern.yaml => tavern_tests/controllers_basic.tavern.yaml} (83%) rename tests/{test_get_all.tavern.yaml => tavern_tests/get_all.tavern.yaml} (100%) create mode 100644 tests/tavern_tests/schedules_basic.tavern.yaml create mode 100644 tests/tavern_tests/schedules_protected.tavern.yaml create mode 100644 tests/tavern_tests/tags.tavern.yaml create mode 100644 tests/tavern_utils/__pycache__/validate_schedule.cpython-38.pyc create mode 100644 tests/tavern_utils/validate_relay.py create mode 100644 tests/tavern_utils/validate_schedule.py delete mode 100644 tests/test_schedules_basic.tavern.yaml delete mode 100644 tests/test_schedules_protected.tavern.yaml delete mode 100644 tests/test_tags.tavern.yaml diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 2fc3cfe..38638a0 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -34,7 +34,8 @@ core_id=$! sleep 2; -tavern-ci --disable-warnings $source_dir +export PYTHONPATH=$PYTHONPATH:$source_dir/tavern_utils +tavern-ci --disable-warnings $source_dir/tavern_tests test_result=$? kill $core_id diff --git a/tests/tavern_tests/controller_relays_basic.tavern.yaml b/tests/tavern_tests/controller_relays_basic.tavern.yaml new file mode 100644 index 0000000..ee59c11 --- /dev/null +++ b/tests/tavern_tests/controller_relays_basic.tavern.yaml @@ -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 diff --git a/tests/test_controllers_basic.tavern.yaml b/tests/tavern_tests/controllers_basic.tavern.yaml similarity index 83% rename from tests/test_controllers_basic.tavern.yaml rename to tests/tavern_tests/controllers_basic.tavern.yaml index 8458ffa..c7bc774 100644 --- a/tests/test_controllers_basic.tavern.yaml +++ b/tests/tavern_tests/controllers_basic.tavern.yaml @@ -1,7 +1,7 @@ test_name: Test basic controller functions stages: -- name: "[test_controllers_basic] discover controllers" +- name: "[controllers_basic] discover controllers" request: method: POST url: "http://localhost:5000/api/v1/controllers/discover/" @@ -21,7 +21,7 @@ stages: returned_name: "[0].name" returned_id: "[0].id" -- name: "[test_controllers_basic] get controller, check name" +- name: "[controllers_basic] get controller, check name" request: method: GET url: "http://localhost:5000/api/v1/controllers/{returned_id}" @@ -37,7 +37,7 @@ stages: ip: !anystr relays: !anylist -- name: "[test_controllers_basic] get controller, check name" +- name: "[controllers_basic] get controller, check name" request: method: PUT url: "http://localhost:5000/api/v1/controllers/{returned_id}" @@ -58,21 +58,21 @@ stages: json: changed_name: "name" -- name: "[test_controllers_basic] delete controller" +- name: "[controllers_basic] delete controller" request: method: DELETE url: "http://localhost:5000/api/v1/controllers/{returned_id}" response: status_code: 200 -- name: "[test_controllers_basic] get controller, expect 404" +- name: "[controllers_basic] get controller, expect 404" request: method: GET url: "http://localhost:5000/api/v1/controllers/{returned_id}" response: status_code: 404 -- name: "[test_controllers_basic] discover controllers again" +- name: "[controllers_basic] discover controllers again" request: method: POST url: "http://localhost:5000/api/v1/controllers/discover/" @@ -88,7 +88,7 @@ stages: ip: !anystr relays: !anylist -- name: "[test_controllers_basic] get controller again, check name" +- name: "[controllers_basic] get controller again, check name" request: method: GET url: "http://localhost:5000/api/v1/controllers/{returned_id}" diff --git a/tests/test_get_all.tavern.yaml b/tests/tavern_tests/get_all.tavern.yaml similarity index 100% rename from tests/test_get_all.tavern.yaml rename to tests/tavern_tests/get_all.tavern.yaml diff --git a/tests/tavern_tests/schedules_basic.tavern.yaml b/tests/tavern_tests/schedules_basic.tavern.yaml new file mode 100644 index 0000000..0cfe93e --- /dev/null +++ b/tests/tavern_tests/schedules_basic.tavern.yaml @@ -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 diff --git a/tests/tavern_tests/schedules_protected.tavern.yaml b/tests/tavern_tests/schedules_protected.tavern.yaml new file mode 100644 index 0000000..dd62064 --- /dev/null +++ b/tests/tavern_tests/schedules_protected.tavern.yaml @@ -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}" diff --git a/tests/tavern_tests/tags.tavern.yaml b/tests/tavern_tests/tags.tavern.yaml new file mode 100644 index 0000000..f3576aa --- /dev/null +++ b/tests/tavern_tests/tags.tavern.yaml @@ -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}" diff --git a/tests/tavern_utils/__pycache__/validate_schedule.cpython-38.pyc b/tests/tavern_utils/__pycache__/validate_schedule.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ca7f6ba6db97e1e3cae430ef4c8ae9dbb8cde723 GIT binary patch literal 3698 zcmbtW&5j$#5uTnu4!K;ew3gTFb*xM_P7DT$cH=0HVihn%%JN!Ofx$^+zV%rOBB_!V?8@>R_YmrE;vk&u}FsjBX-s;>IF ze!solvGBA1_0JE|OP2L-nymj^Oy0n!KR_cbDW=vPOWM+TVBHbYl^%Lq`m%-Ik%4TZ zcV$Ozq4#80Zlm{QPwt>^$xHGw`atf=XVAChp1dNTeIV|1qU9F=1oeKOg5F-EcWU~3pl=a<@m{S#w?66b;B2o>0u?9iEp15Itoaw< z_ju(O(t`CngVIi9{(>G&VtG1^!*|{a6CI|R38PROm82)7n?|!Ze{m&3({Bm2=CMjL zsq?EVxtek=I!(06U;P$;l%*z0QXJTGUAqif5}l+_JsriR za}t}<0juo&TI*PuBujszRHjOo4k%snOW!Gj=Ab)%<-pRx5sxi})Uuwudo;;r@sY_s zOd@?WSJ_AL$mpYZb`qW5i;hN_0yEYindswKrNdK`O!d*n(KL~fiHFVR*XN&4?S0V`yBHntNbQ1tA*(3EXvv%SH0f5w?wNI82xK{;Q4IPv zuPfb;be29AWuRg`&r(=V3##TaMx|e=Kx1vAv4q+~d*MK$uMRxMq&bjNVGpSwnp8Qn zkSJZGq+5U{ti@GU$R6Z-jRqI5x9_O{JE~`>=~A;r4H*p^o~3b*nhmvs+3D0I^Jz?O z(>@wY?1`>W&tWuTLx_go1?8`T0PL{NY7{EOU0WX*yFwvW)fp(VH9u%BEaW^zUXSjE z<0zTN^08B?+lCyg+h|G)H#P0>${}s?JlKtsY5f1{Nv7rdD?Jk#u4}3G!EQ7o(M`>Q zO0z_M56nid1B@@|MZTqvqwQ}P82GLb4{a%=eP*8tprTU%#nD!tbtQ28K6&r$ZJSbBx`(3Sp~D4eRl>!`_Mz|>YvMGxwq7XukAUGQ9e)A)tM5$|E_ zRrtQR$#>WpJP|KH5r>K%!2Hz)4uOrUAdG-VDqfr-W5Wp&Hk8SD9IH4r;WSQ9%tYT- z^mHk*{df5<8&D0$Dw~C760cU@i*z_kH09Acvr4yqi$kUKrdcF)*;4U*8WASp5VeY* z(wpOjFnzxYc+$G;)>;oKgUep6>##tFx&7t2J1FRyT$|7cNNj7l_;X62kuQ+!!-z7(;6sBtZDe|JhlZ zukJt0(x-VZW#@g(&bxN*>XdzVn#O;c<3)~T7|oCy2HtKQ%KqkT&b{N~*N%_#@O^{~ z*J(J4T)(!Q3m#7U+&`4)eaa@oi#-DDjy@Go-F+Wc>}567NYPUI)tq>!vkB-_?bN{Y?e~UKcd6$ zkW#f2M=u`Z!}`Rp3@{gn?XfKCXrQ&D{sO*-Gv8jeq`wRr9%FR7Xk%AG<5tx}{vV4+ zOvUXp6+Nh5E*{DDGFUuX{Iv-5SJ=}f%{~`uf3+*>Z|r($*(o}O3$*x#SA0_hp9{Ue zIIOTk`j}laepR7!v~&mR1vpUAgT;BrPc?_dI$ATptUuuEAVVczjmqjp+J|a_3W`G- zajwx-^|vbg;ir>OugYD5BlQDnxGp)Q(GRJ4iJBi%vr((K<0O^0z|hoKK&4$&DtoB% zY`ba$%xutI&>9S;nQeEN76>1I8=oSC>$?N|pdS}aR4Q@J#4!a@ m^71wPSW~V8gV$#nCB!XCFD^y{JLm;Y;Nf$Eoxl&=!2b^rAaUjZ literal 0 HcmV?d00001 diff --git a/tests/tavern_utils/validate_relay.py b/tests/tavern_utils/validate_relay.py new file mode 100644 index 0000000..0ae475a --- /dev/null +++ b/tests/tavern_utils/validate_relay.py @@ -0,0 +1,2 @@ +def single(response): + assert response.json().get("number") >= 0 diff --git a/tests/tavern_utils/validate_schedule.py b/tests/tavern_utils/validate_schedule.py new file mode 100644 index 0000000..79d1ca6 --- /dev/null +++ b/tests/tavern_utils/validate_schedule.py @@ -0,0 +1,96 @@ +import json + +def _verify_single(schedule): + assert isinstance(schedule.get("id"), str), "schedule ID is not a string" + assert isinstance(schedule.get("name"), str), "schedule name is not a string" + + assert isinstance(schedule.get("periods"), list), "schedule periods is not a list" + for period in schedule.get("periods"): + assert isinstance(period, dict), "schedule periods contain a periods which is not a dict" + assert isinstance(period.get("start"), str), "schedule periods contain a periods with start not being a string" + assert isinstance(period.get("end"), str), "schedule periods contain a periods with end not being a string" + + assert isinstance(schedule.get("tags"), list), "schedule tags is not a list" + for tag in schedule.get("tags"): + assert isinstance(tag, str), "schedule tags contain a tag which is not a string" + +def single(response): + _verify_single(response.json()) + +def multiple(response): + assert isinstance(response.json(), list), "response is not a list" + for schedule in response.json(): + _verify_single(schedule) + +def check_name(response, name): + assert response.json().get("name") == name, "schedule name check failed" + +def check_id(response, id): + assert response.json().get("id") == id, "schedule id check failed" + +def check_periods(response, periods): + periods_json = json.loads(periods.replace("'", "\"")) + assert len(periods_json) == len(response.json().get("periods")), "periods in response and request have different lengths" + for request_period in periods_json: + found_in_response = False + for response_period in response.json().get("periods"): + if response_period.get("start") != request_period.get("start"): + continue + if response_period.get("end") != request_period.get("end"): + continue + found_in_response = True + if not found_in_response: + print(request_period) + assert False, "a period from the request was missing from the response" + +def check_tag(response, tag): + for response_tag in response.json().get("tags"): + if response_tag == tag: + return + assert False, "tag not found in schedule," + +def compare_off(response): + assert response.json().get("id") == "off", "schedule off did not return id off" + assert len(response.json().get("periods")) == 0, "schedule off has periods" + +def compare_on(response): + assert response.json().get("id") == "on", "schedule on did not return id on" + assert len(response.json().get("periods")) == 1, "schedule on has unexpected amount of periods" + assert response.json().get("periods")[0].get("start") == "00:00", "Schedule on has unexpected start" + assert response.json().get("periods")[0].get("end") == "23:59", "Schedule on has unexpected start" + +def find(response, id=None, name=None, periods=None, tag=None): + if periods != None: + periods_json = json.loads(periods.replace("'", "\"")) + for schedule in response.json(): + if id != None and id != schedule.get("id"): + print(schedule.get("id")) + continue + + if name != None and name != schedule.get("name"): + print(schedule.get("name")) + continue + + if periods != None: + if len(periods_json) != len(schedule.get("periods")): + continue + for request_period in periods_json: + found_in_response = False + for response_period in schedule.get("periods"): + if response_period.get("start") != request_period.get("start"): + continue + if response_period.get("end") != request_period.get("end"): + continue + found_in_response = True + if not found_in_response: + continue + + if tag != None: + found_in_response = False + for response_tag in schedule.get("tags"): + if response_tag == tag: + found_in_response = True + if not found_in_response: + continue + return + assert False, "schedule not found in list" diff --git a/tests/test_schedules_basic.tavern.yaml b/tests/test_schedules_basic.tavern.yaml deleted file mode 100644 index f1866c1..0000000 --- a/tests/test_schedules_basic.tavern.yaml +++ /dev/null @@ -1,58 +0,0 @@ -test_name: Test basic schedule 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 - json: - name: "{tavern.request_vars.json.name}" - id: !anystr - periods: !anylist - tags: !anylist - save: - json: - 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 - json: - name: "{returned_name}" - id: !anystr - periods: !anylist - tags: !anylist - -- 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 diff --git a/tests/test_schedules_protected.tavern.yaml b/tests/test_schedules_protected.tavern.yaml deleted file mode 100644 index ae420c3..0000000 --- a/tests/test_schedules_protected.tavern.yaml +++ /dev/null @@ -1,78 +0,0 @@ -test_name: Test protected schedules 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 - json: - id: "off" - name: "off" - periods: [] - tags: !anylist - -- 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 - json: - id: "off" - name: "{tavern.request_vars.json.name}" - periods: [] - tags: !anylist - -- 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 - json: - id: "on" - name: "on" - periods: - - start: "00:00" - end: "23:59" - tags: !anylist - -- 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 - json: - id: "on" - name: "{tavern.request_vars.json.name}" - periods: - - start: "00:00" - end: "23:59" - tags: !anylist diff --git a/tests/test_tags.tavern.yaml b/tests/test_tags.tavern.yaml deleted file mode 100644 index ff2b1ec..0000000 --- a/tests/test_tags.tavern.yaml +++ /dev/null @@ -1,43 +0,0 @@ -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 - json: - id: !anystr - name: "{tavern.request_vars.json.name}" - periods: - - start: "00:50" - end: "01:00" - tags: - - "{tavern.request_vars.json.tags[0]}" - save: - json: - returned_name: name - returned_id: id - -- 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 - json: - - name: "{returned_name}" - id: "{returned_id}" - periods: - - start: "00:50" - end: "01:00" - tags: - - "test_tag_1"