add: tests and test_script
This commit is contained in:
		
							parent
							
								
									51ab1d7982
								
							
						
					
					
						commit
						2a4e0e1075
					
				
					 5 changed files with 83 additions and 14 deletions
				
			
		
							
								
								
									
										17
									
								
								tavern_tests/run_tests.sh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								tavern_tests/run_tests.sh
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
#!/usr/bin/env sh
 | 
			
		||||
 | 
			
		||||
mkdir ./testing_tmp
 | 
			
		||||
cd ./testing_tmp
 | 
			
		||||
 | 
			
		||||
cp $1 ./core
 | 
			
		||||
cp $2 ./config.json
 | 
			
		||||
 | 
			
		||||
./core &
 | 
			
		||||
core_id=$!
 | 
			
		||||
 | 
			
		||||
sleep 2;
 | 
			
		||||
 | 
			
		||||
tavern-ci --tavern-beta-new-traceback ..
 | 
			
		||||
kill $core_id
 | 
			
		||||
cd ..
 | 
			
		||||
rm -r ./testing_tmp
 | 
			
		||||
| 
						 | 
				
			
			@ -36,4 +36,15 @@ stages:
 | 
			
		|||
          status_code: 200
 | 
			
		||||
          body:
 | 
			
		||||
              name: "{returned_name}"
 | 
			
		||||
 | 
			
		||||
    - name: delete schedule
 | 
			
		||||
      request:
 | 
			
		||||
          method: DELETE
 | 
			
		||||
          url: "http://localhost:5000/api/v1/schedules/{returned_id}"
 | 
			
		||||
      response:
 | 
			
		||||
          status_code: 200
 | 
			
		||||
    - name: get deleted schedule, expect 404
 | 
			
		||||
      request:
 | 
			
		||||
          method: GET
 | 
			
		||||
          url: "http://localhost:5000/api/v1/schedules/{returned_id}"
 | 
			
		||||
      response:
 | 
			
		||||
          status_code: 404
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										45
									
								
								tavern_tests/test_schedules_protected.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								tavern_tests/test_schedules_protected.tavern.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
test_name: Test basic requests
 | 
			
		||||
 | 
			
		||||
stages:
 | 
			
		||||
    - name: delete protected off schedule; expect forbidden/fail
 | 
			
		||||
      request:
 | 
			
		||||
          method: DELETE
 | 
			
		||||
          url: "http://localhost:5000/api/v1/schedules/off"
 | 
			
		||||
      response:
 | 
			
		||||
          status_code: 403
 | 
			
		||||
    - name: get protected off schedule
 | 
			
		||||
      request:
 | 
			
		||||
          method: GET
 | 
			
		||||
          url: "http://localhost:5000/api/v1/schedules/off"
 | 
			
		||||
      response:
 | 
			
		||||
          status_code: 200
 | 
			
		||||
          body:
 | 
			
		||||
              name: "off"
 | 
			
		||||
              periods: []
 | 
			
		||||
    - name: 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
 | 
			
		||||
          body:
 | 
			
		||||
              name: "{tavern.request_vars.json.name}"
 | 
			
		||||
              periods: []
 | 
			
		||||
 | 
			
		||||
    - name: 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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue