REFACTOR
This commit is contained in:
		
							parent
							
								
									0460b2e9f7
								
							
						
					
					
						commit
						176483d72f
					
				
					 59 changed files with 11 additions and 45 deletions
				
			
		| 
						 | 
				
			
			@ -1,23 +0,0 @@
 | 
			
		|||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,116 +0,0 @@
 | 
			
		|||
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
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_controller:multiple
 | 
			
		||||
    save:
 | 
			
		||||
      json:
 | 
			
		||||
        returned_name: "[0].name"
 | 
			
		||||
        returned_id: "[0].id"
 | 
			
		||||
        returned_ip: "[0].ip"
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_basic] get controller, check name"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_controller:single
 | 
			
		||||
      function: validate_controller:check_id
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        id: "{returned_id}"
 | 
			
		||||
      function: validate_controller:check_name
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        name: "{returned_name}"
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_basic] put controller, check name"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
    json:
 | 
			
		||||
      name: "renamed_controller"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_controller:single
 | 
			
		||||
      function: validate_controller:check_id
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        id: "{returned_id}"
 | 
			
		||||
      function: validate_controller:check_name
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        name: "{tavern.request_vars.json.name}"
 | 
			
		||||
    save:
 | 
			
		||||
      json:
 | 
			
		||||
        changed_name: "name"
 | 
			
		||||
 | 
			
		||||
#- name: "[controllers_basic] put controller, check name and ip"
 | 
			
		||||
#  request:
 | 
			
		||||
#    method: PUT
 | 
			
		||||
#    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
#    json:
 | 
			
		||||
#      ip: "203.0.113.17"
 | 
			
		||||
#  response:
 | 
			
		||||
#    status_code: 200
 | 
			
		||||
#    verify_response_with:
 | 
			
		||||
#      function: validate_controller:single
 | 
			
		||||
#      function: validate_controller:check_id
 | 
			
		||||
#      extra_kwargs:
 | 
			
		||||
#        id: "{returned_id}"
 | 
			
		||||
#      function: validate_controller:check_ip
 | 
			
		||||
#      extra_kwargs:
 | 
			
		||||
#        ip: "{tavern.request_vars.json.ip}"
 | 
			
		||||
#    save:
 | 
			
		||||
#      json:
 | 
			
		||||
#        changed_ip: "ip"
 | 
			
		||||
 | 
			
		||||
- 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
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_controller:multiple
 | 
			
		||||
      function: validate_controller:find
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        id: "{returned_id}"
 | 
			
		||||
        name: "{changed_name}"
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_basic] get controller again, check name"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_controller:single
 | 
			
		||||
      function: validate_controller:check_id
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        id: "{returned_id}"
 | 
			
		||||
      function: validate_controller:check_name
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        name: "{changed_name}"
 | 
			
		||||
      function: validate_controller:check_ip
 | 
			
		||||
      extra_kwargs:
 | 
			
		||||
        ip: "{returned_ip}"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
test_name: Test basic controller relays functions
 | 
			
		||||
 | 
			
		||||
stages:
 | 
			
		||||
- name: "[controller_relays_basic] get controllers"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    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:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    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:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/5"
 | 
			
		||||
  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: 5
 | 
			
		||||
| 
						 | 
				
			
			@ -1,99 +0,0 @@
 | 
			
		|||
test_name: Test bad controller functions
 | 
			
		||||
 | 
			
		||||
stages:
 | 
			
		||||
- name: "[controllers_bad] get controller with bad id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/this_id_is_invalid"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] put controller with bad id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/this_id_is_invalid"
 | 
			
		||||
    json:
 | 
			
		||||
      name: "unknown_controller"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] delete controller with bad id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: DELETE
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/this_id_is_invalid"
 | 
			
		||||
    json:
 | 
			
		||||
      name: "unknown_controller"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] get controller with unknown id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/00000000-0000-0000-0000-000000000000"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 404
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] put controller with unknown id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/00000000-0000-0000-0000-000000000000"
 | 
			
		||||
    json:
 | 
			
		||||
      name: "unknown_controller"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 404
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] delete controller with unknown id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: DELETE
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/00000000-0000-0000-0000-000000000000"
 | 
			
		||||
    json:
 | 
			
		||||
      name: "unknown_controller"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 404
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] get controllers to save valid id"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_controller:multiple
 | 
			
		||||
    save:
 | 
			
		||||
      json:
 | 
			
		||||
        returned_id: "[0].id"
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] put controller with bad body (invalid name)"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
    json:
 | 
			
		||||
      name: NULL
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] put controller with bad body (invalid ip)"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
    json:
 | 
			
		||||
      ip: 123
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] put controller with bad body (invalid IPv4)"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
    json:
 | 
			
		||||
      ip: "10.0.0.300"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[controllers_bad] put controller with bad body (no json)"
 | 
			
		||||
  request:
 | 
			
		||||
    method: PUT
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/{returned_id}"
 | 
			
		||||
    data: "<b>not json</b><i>but html</i>"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
| 
						 | 
				
			
			@ -1,87 +0,0 @@
 | 
			
		|||
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 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
 | 
			
		||||
    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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,72 +0,0 @@
 | 
			
		|||
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}"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,145 +0,0 @@
 | 
			
		|||
test_name: Test bad schedule requests
 | 
			
		||||
 | 
			
		||||
stages:
 | 
			
		||||
- name: "[schedules_bad] 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_bad] 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_bad] 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_bad] 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_bad] 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_bad] 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_bad] 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_bad] 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_bad] 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
 | 
			
		||||
 | 
			
		||||
- name: "[schedules_bad] post schedule with bad periods (invalid list)"
 | 
			
		||||
  request:
 | 
			
		||||
    method: POST
 | 
			
		||||
    url: "http://localhost:5000/api/v1/schedules/"
 | 
			
		||||
    json:
 | 
			
		||||
      name: "i am nvalid"
 | 
			
		||||
      periods: "not a list"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
 | 
			
		||||
- name: "[schedules_bad] post schedule with bad tags (one invalid)"
 | 
			
		||||
  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"
 | 
			
		||||
      tags:
 | 
			
		||||
      - "valid_tag"
 | 
			
		||||
      - 123
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 400
 | 
			
		||||
| 
						 | 
				
			
			@ -1,108 +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
 | 
			
		||||
    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}"
 | 
			
		||||
 | 
			
		||||
- name: "[tags] get controllers"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/"
 | 
			
		||||
  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}"
 | 
			
		||||
 | 
			
		||||
- name: "[tags] get tags"
 | 
			
		||||
  request:
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/tags/"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
      function: validate_tag:multiple
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue