#!/usr/bin/env python3 """ Simple test script for file upload API """ import requests import os from pathlib import Path def test_upload_api(): """Test the file upload API""" base_url = "http://localhost:5000/api" # Test health check print("Testing health check...") try: response = requests.get(f"{base_url}/health") print(f"Health check: {response.status_code} - {response.json()}") except Exception as e: print(f"Health check failed: {e}") return # Test file upload with blade.step blade_file = Path("resource/blade.step") if blade_file.exists(): print(f"\nTesting file upload with {blade_file}...") try: with open(blade_file, 'rb') as f: files = {'file': (blade_file.name, f, 'application/octet-stream')} response = requests.post(f"{base_url}/upload", files=files) print(f"Upload response: {response.status_code}") print(f"Response data: {response.json()}") except Exception as e: print(f"Upload test failed: {e}") else: print(f"Test file {blade_file} not found") # Test get current file print("\nTesting get current file...") try: response = requests.get(f"{base_url}/files/current") print(f"Current file: {response.status_code} - {response.json()}") except Exception as e: print(f"Get current file failed: {e}") # Test mesh status print("\nTesting mesh status...") try: response = requests.get(f"{base_url}/mesh/status") print(f"Mesh status: {response.status_code} - {response.json()}") except Exception as e: print(f"Mesh status failed: {e}") if __name__ == '__main__': print("CAE Mesh Generator API Test") print("Make sure the server is running on http://localhost:5000") print("=" * 50) test_upload_api()