Spaces:
Running
Running
| ο»Ώ#!/usr/bin/env python3 | |
| """ | |
| Simple build test to check if the application can import and start | |
| """ | |
| def test_imports(): | |
| """Test if all required imports work""" | |
| print("π§ͺ Testing imports...") | |
| try: | |
| import os | |
| import torch | |
| import tempfile | |
| import gradio as gr | |
| from fastapi import FastAPI, HTTPException | |
| print("β Basic imports successful") | |
| except ImportError as e: | |
| print(f"β Basic import failed: {e}") | |
| return False | |
| try: | |
| import logging | |
| import asyncio | |
| from typing import Optional | |
| print("β Standard library imports successful") | |
| except ImportError as e: | |
| print(f"β Standard library import failed: {e}") | |
| return False | |
| try: | |
| from robust_tts_client import RobustTTSClient | |
| print("β Robust TTS client import successful") | |
| except ImportError as e: | |
| print(f"β Robust TTS client import failed: {e}") | |
| return False | |
| try: | |
| from advanced_tts_client import AdvancedTTSClient | |
| print("β Advanced TTS client import successful") | |
| except ImportError as e: | |
| print(f"β οΈ Advanced TTS client import failed (this is OK): {e}") | |
| return True | |
| def test_app_creation(): | |
| """Test if the app can be created""" | |
| print("\nποΈ Testing app creation...") | |
| try: | |
| # Import the main app components | |
| from app import app, omni_api, TTSManager | |
| print("β App components imported successfully") | |
| # Test TTS manager creation | |
| tts_manager = TTSManager() | |
| print("β TTS manager created successfully") | |
| # Test app instance | |
| if app: | |
| print("β FastAPI app created successfully") | |
| return True | |
| except Exception as e: | |
| print(f"β App creation failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| return False | |
| def main(): | |
| """Run all tests""" | |
| print("π BUILD TEST SUITE") | |
| print("=" * 50) | |
| tests = [ | |
| ("Import Test", test_imports), | |
| ("App Creation Test", test_app_creation) | |
| ] | |
| results = [] | |
| for name, test_func in tests: | |
| try: | |
| result = test_func() | |
| results.append((name, result)) | |
| except Exception as e: | |
| print(f"β {name} crashed: {e}") | |
| results.append((name, False)) | |
| # Summary | |
| print("\n" + "=" * 50) | |
| print("TEST RESULTS") | |
| print("=" * 50) | |
| for name, result in results: | |
| status = "β PASS" if result else "β FAIL" | |
| print(f"{name}: {status}") | |
| passed = sum(1 for _, result in results if result) | |
| total = len(results) | |
| print(f"\nOverall: {passed}/{total} tests passed") | |
| if passed == total: | |
| print("π BUILD SUCCESSFUL! The application should start correctly.") | |
| return True | |
| else: | |
| print("π₯ BUILD FAILED! Check the errors above.") | |
| return False | |
| if __name__ == "__main__": | |
| success = main() | |
| exit(0 if success else 1) | |