Download test_web_ui.py from pravinai/InklyAI: direct link, hf CLI and curl.
- Browser
- Download file 4.31 kB
-
https://huggingface.co/pravinai/InklyAI/resolve/main/test_web_ui.py
- Command line
-
hf download hf://pravinai/InklyAI/test_web_ui.py
-
curl -L -o test_web_ui.py https://huggingface.co/pravinai/InklyAI/resolve/main/test_web_ui.py
4.31 kB
| """ | |
| Test script for InklyAI Web UI | |
| """ | |
| import requests | |
| import json | |
| import os | |
| import time | |
| from pathlib import Path | |
| def test_web_ui(): | |
| """Test the web UI functionality.""" | |
| print("π§ͺ Testing InklyAI Web UI") | |
| print("=" * 50) | |
| base_url = "http://localhost:8080" | |
| # Test 1: Health check | |
| print("\n1. Testing health check...") | |
| try: | |
| response = requests.get(f"{base_url}/api/health") | |
| health = response.json() | |
| print(f" β Health status: {health['status']}") | |
| print(f" β Agents registered: {health['agents_registered']}") | |
| except Exception as e: | |
| print(f" β Health check failed: {e}") | |
| return False | |
| # Test 2: Get agents | |
| print("\n2. Testing agent listing...") | |
| try: | |
| response = requests.get(f"{base_url}/api/agents") | |
| agents = response.json() | |
| print(f" β Found {agents['total_agents']} agents") | |
| for agent in agents['agents']: | |
| print(f" - {agent['agent_id']} ({'Active' if agent['is_active'] else 'Inactive'})") | |
| except Exception as e: | |
| print(f" β Agent listing failed: {e}") | |
| # Test 3: Test signature verification (if sample data exists) | |
| print("\n3. Testing signature verification...") | |
| if os.path.exists('data/samples/john_doe_1.png') and os.path.exists('data/samples/john_doe_2.png'): | |
| try: | |
| # Test with sample signatures | |
| with open('data/samples/john_doe_1.png', 'rb') as f1, open('data/samples/john_doe_2.png', 'rb') as f2: | |
| files = { | |
| 'signature1': ('john_doe_1.png', f1, 'image/png'), | |
| 'signature2': ('john_doe_2.png', f2, 'image/png') | |
| } | |
| data = {'agent_id': 'Agent_01'} | |
| response = requests.post(f"{base_url}/api/verify", files=files, data=data) | |
| result = response.json() | |
| if result['success']: | |
| print(f" β Verification successful") | |
| print(f" β Similarity: {result['similarity_score']:.3f}") | |
| print(f" β Verified: {result['is_verified']}") | |
| else: | |
| print(f" β Verification failed: {result['error']}") | |
| except Exception as e: | |
| print(f" β Signature verification failed: {e}") | |
| else: | |
| print(" β οΈ Sample data not found. Run demo.py first to create sample signatures.") | |
| # Test 4: Test agent stats | |
| print("\n4. Testing agent statistics...") | |
| try: | |
| response = requests.get(f"{base_url}/api/stats") | |
| stats = response.json() | |
| if stats['success']: | |
| print(f" β Statistics loaded successfully") | |
| for agent_id, agent_stats in stats['stats'].items(): | |
| print(f" - {agent_id}: {agent_stats['total_verifications']} verifications, " | |
| f"success rate: {agent_stats['success_rate']:.1%}") | |
| else: | |
| print(f" β Stats failed: {stats['error']}") | |
| except Exception as e: | |
| print(f" β Agent stats failed: {e}") | |
| print("\nπ Web UI tests completed!") | |
| print(f"\nπ Access the web UI at: {base_url}") | |
| print(f"π Agent management at: {base_url}/agents") | |
| return True | |
| def check_web_server(): | |
| """Check if the web server is running.""" | |
| try: | |
| response = requests.get("http://localhost:8080/api/health", timeout=5) | |
| return response.status_code == 200 | |
| except: | |
| return False | |
| if __name__ == "__main__": | |
| print("InklyAI Web UI Test Suite") | |
| print("=" * 50) | |
| # Check if web server is running | |
| if not check_web_server(): | |
| print("β Web server is not running!") | |
| print("Please start the web server with:") | |
| print(" python web_app.py") | |
| print("\nThen run this test script again.") | |
| exit(1) | |
| print("β Web server is running") | |
| # Run tests | |
| test_web_ui() | |
| print("\n" + "=" * 50) | |
| print("Web UI Test Summary:") | |
| print("β Health monitoring") | |
| print("β Agent management") | |
| print("β Signature verification") | |
| print("β Statistics and reporting") | |
| print("β Error handling") | |
| print("\nπ Web UI is ready for use!") | |