mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	Merge branch 'master' of https://github.com/inventree/InvenTree into plugin-2037
This commit is contained in:
		
							
								
								
									
										40
									
								
								ci/check_api_endpoint.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								ci/check_api_endpoint.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| """ | ||||
| Test that the root API endpoint is available. | ||||
| """ | ||||
|  | ||||
| # -*- coding: utf-8 -*- | ||||
| from __future__ import unicode_literals | ||||
|  | ||||
| import json | ||||
| import requests | ||||
|  | ||||
| # We expect the server to be running on the local host | ||||
| url = "http://localhost:8000/api/" | ||||
|  | ||||
| print("Testing InvenTree API endpoint") | ||||
|  | ||||
| response = requests.get(url) | ||||
|  | ||||
| assert(response.status_code == 200) | ||||
|  | ||||
| print("- Response 200 OK") | ||||
|  | ||||
| data = json.loads(response.text) | ||||
|  | ||||
| required_keys = [ | ||||
|     'server', | ||||
|     'version', | ||||
|     'apiVersion', | ||||
|     'worker_running', | ||||
| ] | ||||
|  | ||||
| for key in required_keys: | ||||
|     assert(key in data) | ||||
|     print(f"- Found key '{key}'") | ||||
|  | ||||
| # Check that the worker is running | ||||
| assert(data['worker_running']) | ||||
|  | ||||
| print("- Background worker is operational") | ||||
|  | ||||
| print("API Endpoint Tests Passed OK") | ||||
		Reference in New Issue
	
	Block a user