add: tests
This commit is contained in:
		
							parent
							
								
									760cec9a20
								
							
						
					
					
						commit
						865caa627e
					
				
					 15 changed files with 558 additions and 386 deletions
				
			
		
							
								
								
									
										116
									
								
								tests/tavern_tests/1.0.controllers_basic.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								tests/tavern_tests/1.0.controllers_basic.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,116 @@
 | 
			
		|||
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,10 +1,10 @@
 | 
			
		|||
test_name: Test basic controller relays functions
 | 
			
		||||
 | 
			
		||||
stages:
 | 
			
		||||
- name: "[controller_relays_basic] discover controllers"
 | 
			
		||||
- name: "[controller_relays_basic] get controllers"
 | 
			
		||||
  request:
 | 
			
		||||
    method: POST
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/discover/"
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
							
								
								
									
										99
									
								
								tests/tavern_tests/1.2.controllers_bad.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								tests/tavern_tests/1.2.controllers_bad.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,99 @@
 | 
			
		|||
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
 | 
			
		||||
							
								
								
									
										87
									
								
								tests/tavern_tests/2.0.schedules_basic.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								tests/tavern_tests/2.0.schedules_basic.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,87 @@
 | 
			
		|||
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
 | 
			
		||||
							
								
								
									
										145
									
								
								tests/tavern_tests/2.2.schedules_bad.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										145
									
								
								tests/tavern_tests/2.2.schedules_bad.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,145 @@
 | 
			
		|||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -45,10 +45,10 @@ stages:
 | 
			
		|||
        name: "{returned_name}"
 | 
			
		||||
        periods: "{returned_periods}"
 | 
			
		||||
 | 
			
		||||
- name: "[tags] discover controllers"
 | 
			
		||||
- name: "[tags] get controllers"
 | 
			
		||||
  request:
 | 
			
		||||
    method: POST
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/discover/"
 | 
			
		||||
    method: GET
 | 
			
		||||
    url: "http://localhost:5000/api/v1/controllers/"
 | 
			
		||||
  response:
 | 
			
		||||
    status_code: 200
 | 
			
		||||
    verify_response_with:
 | 
			
		||||
| 
						 | 
				
			
			@ -1,105 +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
 | 
			
		||||
    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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,201 +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
 | 
			
		||||
 | 
			
		||||
- 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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue