#!/usr/bin/env python3 """ Phase 6 Deployment Readiness Test Comprehensive validation that all improvements are ready for HuggingFace deployment. """ import sys import os from pathlib import Path import importlib.util # Add current directory to path sys.path.insert(0, str(Path(__file__).parent)) def test_core_components(): """Test that all core components are available.""" print("šŸ” Testing Core Components...") # Test agent imports try: from agents.fixed_enhanced_unified_agno_agent import FixedGAIAAgent print("āœ… Fixed GAIA Agent import successful") except ImportError as e: print(f"āŒ Fixed GAIA Agent import failed: {e}") return False # Test calculator prompt enhancer try: from utils.calculator_prompt_enhancer import CalculatorPromptEnhancer print("āœ… Calculator Prompt Enhancer import successful") except ImportError as e: print(f"āŒ Calculator Prompt Enhancer import failed: {e}") return False # Test response processor try: from utils.response_processor import EnhancedResponseProcessor print("āœ… Enhanced Response Processor import successful") except ImportError as e: print(f"āŒ Enhanced Response Processor import failed: {e}") return False # Test file handler try: from utils.file_handler import EnhancedFileHandler print("āœ… Enhanced File Handler import successful") except ImportError as e: print(f"āŒ Enhanced File Handler import failed: {e}") return False return True def test_app_functionality(): """Test that the main app.py is functional.""" print("\nšŸ” Testing App Functionality...") try: # Test app import spec = importlib.util.spec_from_file_location("app", "app.py") app_module = importlib.util.module_from_spec(spec) # Check if app has required functions spec.loader.exec_module(app_module) if hasattr(app_module, 'setup_environment'): print("āœ… App has setup_environment function") elif hasattr(app_module, 'DeploymentReadyGAIAAgent'): print("āœ… App has DeploymentReadyGAIAAgent class") else: print("āŒ App missing required components") return False return True except Exception as e: print(f"āŒ App functionality test failed: {e}") return False def test_calculator_improvements(): """Test that calculator improvements are working.""" print("\nšŸ” Testing Calculator Improvements...") try: from utils.calculator_prompt_enhancer import CalculatorPromptEnhancer enhancer = CalculatorPromptEnhancer() # Test exponentiation detection test_cases = [ "What is 2 to the power of 8?", "Calculate 2^8", "What is 2**8?" ] for test_case in test_cases: enhanced = enhancer.enhance_prompt_for_exponentiation(test_case) if "Python" in enhanced or "python" in enhanced: print(f"āœ… Exponentiation enhancement working: {test_case}") else: print(f"āš ļø Enhancement may not be working: {test_case}") return True except Exception as e: print(f"āŒ Calculator improvements test failed: {e}") return False def test_file_structure(): """Test that all required files are present.""" print("\nšŸ” Testing File Structure...") required_files = [ "app.py", "requirements.txt", "push_to_hf.py", "agents/fixed_enhanced_unified_agno_agent.py", "utils/calculator_prompt_enhancer.py", "utils/response_processor.py", "utils/file_handler.py", "utils/environment_setup.py" ] missing_files = [] for file_path in required_files: if Path(file_path).exists(): print(f"āœ… {file_path}") else: print(f"āŒ Missing: {file_path}") missing_files.append(file_path) return len(missing_files) == 0 def test_phase_improvements(): """Test that all phase improvements are integrated.""" print("\nšŸ” Testing Phase Improvements Integration...") # Check Phase 1-5 test results test_files = [ "tests/test_calculator_accuracy_100.py", "tests/test_calculator_exponentiation_fix.py", "tests/test_agent_prompt_enhancer_integration.py", "tests/test_response_processor.py", "tests/test_file_handler.py" ] available_tests = [] for test_file in test_files: if Path(test_file).exists(): print(f"āœ… {test_file}") available_tests.append(test_file) else: print(f"āš ļø Test not found: {test_file}") print(f"šŸ“Š Available test suites: {len(available_tests)}/{len(test_files)}") return len(available_tests) >= 3 # At least 3 test suites should be available def test_deployment_script(): """Test that deployment script is ready.""" print("\nšŸ” Testing Deployment Script...") try: from push_to_hf import push_to_huggingface print("āœ… HuggingFace deployment script import successful") # Check if script has proper error handling if "HF_TOKEN" in open("push_to_hf.py").read(): print("āœ… Deployment script checks for HF_TOKEN") else: print("āŒ Deployment script missing HF_TOKEN check") return False return True except Exception as e: print(f"āŒ Deployment script test failed: {e}") return False def main(): """Run comprehensive deployment readiness test.""" print("šŸš€ Phase 6 Deployment Readiness Test") print("=" * 50) tests = [ ("Core Components", test_core_components), ("App Functionality", test_app_functionality), ("Calculator Improvements", test_calculator_improvements), ("File Structure", test_file_structure), ("Phase Improvements", test_phase_improvements), ("Deployment Script", test_deployment_script) ] passed_tests = 0 total_tests = len(tests) for test_name, test_func in tests: try: if test_func(): passed_tests += 1 print(f"āœ… {test_name}: PASSED") else: print(f"āŒ {test_name}: FAILED") except Exception as e: print(f"āŒ {test_name}: ERROR - {e}") print("\n" + "=" * 50) print(f"šŸ“Š Test Results: {passed_tests}/{total_tests} tests passed") if passed_tests == total_tests: print("šŸŽ‰ DEPLOYMENT READY! All tests passed.") print("šŸš€ Ready to push to HuggingFace Space with:") print(" cd deployment-ready && python push_to_hf.py") return True else: print("āš ļø Some tests failed. Please review before deployment.") return False if __name__ == "__main__": success = main() sys.exit(0 if success else 1)