Spaces:
Running
Running
| #!/usr/bin/env python3 | |
| """ | |
| Test Stage 0: Pre-flight validation integration | |
| """ | |
| import logging | |
| from pathlib import Path | |
| from agent.pipeline_engine import OvergrowthPipeline, NetworkIntent | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def test_preflight_pass(): | |
| """Test pre-flight with valid network""" | |
| print("\n=== Test 1: Pre-flight Validation - PASS ===") | |
| pipeline = OvergrowthPipeline() | |
| # Create a good network intent | |
| intent = NetworkIntent( | |
| description="Corporate office network with guest WiFi", | |
| business_requirements=["Secure guest access", "High availability", "QoS for VoIP"], | |
| constraints=["Budget under $15K", "Cisco preferred"], | |
| budget="$15000", | |
| timeline="2 weeks" | |
| ) | |
| # Generate source of truth | |
| model = pipeline.stage2_generate_sot(intent) | |
| # Run pre-flight validation | |
| results = pipeline.stage0_preflight(model) | |
| print(f"\nValidation Results:") | |
| print(f" Schema Valid: {results['schema_valid']}") | |
| print(f" Policy Passed: {results['policy_passed']}") | |
| print(f" Ready to Deploy: {results['ready_to_deploy']}") | |
| print(f" Errors: {len(results['errors'])}") | |
| print(f" Warnings: {len(results['warnings'])}") | |
| print(f" Info: {len(results['info'])}") | |
| if results['errors']: | |
| print("\nErrors:") | |
| for err in results['errors']: | |
| print(f" - {err}") | |
| if results['warnings']: | |
| print("\nWarnings:") | |
| for warn in results['warnings'][:5]: # Show first 5 | |
| print(f" - {warn}") | |
| if results['ready_to_deploy']: | |
| print("\n✓ Pre-flight validation PASSED - ready to deploy") | |
| else: | |
| print("\n✗ Pre-flight validation FAILED") | |
| def test_full_pipeline_with_validation(): | |
| """Test complete pipeline including pre-flight""" | |
| print("\n=== Test 2: Full Pipeline with Validation ===") | |
| pipeline = OvergrowthPipeline() | |
| consultation = "I need a network for a small retail store with guest WiFi, employee WiFi, POS systems, and security cameras. Budget is $5000." | |
| results = pipeline.run_full_pipeline(consultation) | |
| print(f"\nPipeline Results:") | |
| print(f" Intent captured: {'intent' in results}") | |
| print(f" Model generated: {'model' in results}") | |
| print(f" Pre-flight complete: {'preflight' in results}") | |
| if 'preflight' in results: | |
| pf = results['preflight'] | |
| print(f"\nPre-flight:") | |
| print(f" Ready to deploy: {pf['ready_to_deploy']}") | |
| print(f" Errors: {len(pf['errors'])}") | |
| print(f" Warnings: {len(pf['warnings'])}") | |
| if 'deployment_status' in results: | |
| print(f"\nDeployment Status: {results['deployment_status']}") | |
| if 'deployment_reason' in results: | |
| print(f" Reason: {results['deployment_reason']}") | |
| print(f"\nOutputs:") | |
| print(f" Diagrams: {'diagrams' in results}") | |
| print(f" BOM: {'bom' in results}") | |
| print(f" Setup Guide: {'setup_guide' in results}") | |
| if 'bom' in results: | |
| bom = results['bom'] | |
| print(f"\nBill of Materials:") | |
| print(f" Total Cost: ${bom.get('total_estimated_cost', 0):,.2f}") | |
| print(f" Devices: {len(bom.get('devices', []))}") | |
| print("\n✓ Full pipeline test complete") | |
| if __name__ == "__main__": | |
| print("\n" + "="*60) | |
| print("Stage 0: Pre-flight Validation Test") | |
| print("="*60) | |
| try: | |
| test_preflight_pass() | |
| test_full_pipeline_with_validation() | |
| print("\n" + "="*60) | |
| print("✓ All pre-flight tests passed!") | |
| print("="*60 + "\n") | |
| except Exception as e: | |
| print(f"\n✗ Test failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| exit(1) | |