#!/usr/bin/env python3 """Demo script for the enhanced video processing test dashboard.""" import sys from pathlib import Path from datetime import datetime import random # Add tests framework to path sys.path.append(str(Path(__file__).parent / "tests" / "framework")) from enhanced_dashboard_reporter import EnhancedDashboardReporter from reporters import TestResult from config import TestingConfig from quality import TestQualityMetrics def generate_sample_test_data(): """Generate sample test data for dashboard demonstration.""" test_results = [] # Video encoding tests video_tests = [ ("test_h264_encoding.py::test_basic_h264", "passed", "unit", 1.23, 9.1), ("test_h264_encoding.py::test_high_quality_h264", "passed", "unit", 2.45, 9.3), ("test_h265_encoding.py::test_basic_h265", "passed", "unit", 1.87, 8.9), ("test_av1_encoding.py::test_basic_av1", "failed", "unit", 5.67, 4.2), ("test_webm_encoding.py::test_vp9_encoding", "passed", "unit", 3.21, 8.7), ] # Performance tests performance_tests = [ ("test_performance.py::test_encoding_speed", "passed", "performance", 15.34, 8.5), ("test_performance.py::test_memory_usage", "passed", "performance", 8.91, 8.8), ("test_performance.py::test_cpu_utilization", "failed", "performance", 12.45, 6.2), ("test_performance.py::test_gpu_acceleration", "skipped", "performance", 0.01, 0.0), ] # 360° video tests video_360_tests = [ ("test_360_processing.py::test_equirectangular", "passed", "360", 8.76, 8.9), ("test_360_processing.py::test_cubemap_projection", "failed", "360", 7.23, 5.1), ("test_360_processing.py::test_spherical_metadata", "passed", "360", 2.14, 9.0), ] # Streaming tests streaming_tests = [ ("test_streaming.py::test_hls_segmentation", "passed", "streaming", 4.56, 8.6), ("test_streaming.py::test_dash_manifest", "passed", "streaming", 3.21, 8.4), ("test_streaming.py::test_adaptive_bitrate", "passed", "streaming", 6.78, 8.8), ] # Integration tests integration_tests = [ ("test_integration.py::test_end_to_end_workflow", "passed", "integration", 25.67, 8.7), ("test_integration.py::test_ffmpeg_integration", "passed", "integration", 12.34, 8.9), ("test_integration.py::test_database_operations", "failed", "integration", 8.91, 5.8), ("test_integration.py::test_api_endpoints", "passed", "integration", 6.45, 8.5), ] # Smoke tests smoke_tests = [ ("test_smoke.py::test_basic_functionality", "passed", "smoke", 0.45, 9.0), ("test_smoke.py::test_system_health", "passed", "smoke", 0.67, 8.9), ("test_smoke.py::test_dependencies", "passed", "smoke", 0.23, 9.1), ] all_tests = video_tests + performance_tests + video_360_tests + streaming_tests + integration_tests + smoke_tests for name, status, category, duration, quality_score in all_tests: # Create quality metrics quality_metrics = None if quality_score > 0: quality_metrics = TestQualityMetrics( test_name=name, overall_score=quality_score, functional_score=quality_score + random.uniform(-0.5, 0.5), performance_score=quality_score + random.uniform(-0.8, 0.3), reliability_score=quality_score + random.uniform(-0.3, 0.7), coverage_score=quality_score + random.uniform(-0.4, 0.6), maintainability_score=quality_score + random.uniform(-0.6, 0.4) ) # Create test result test_result = TestResult( name=name, status=status, duration=duration, category=category, error_message="Encoding failed: Invalid codec parameters" if status == "failed" else None, artifacts=["screenshot.png", "output.mp4"] if status != "skipped" else [], quality_metrics=quality_metrics ) test_results.append(test_result) return test_results def main(): """Generate and save the enhanced dashboard.""" print("šŸŽ¬ Generating Enhanced Video Processing Test Dashboard...") # Create testing configuration config = TestingConfig( project_name="Video Processor", version="1.0.0", reports_dir=Path("test-reports"), parallel_workers=4 ) # Create the enhanced reporter reporter = EnhancedDashboardReporter(config) # Generate sample test data test_results = generate_sample_test_data() # Add test results to reporter for result in test_results: reporter.add_test_result(result) # Generate and save the dashboard dashboard_path = reporter.save_dashboard() print(f"āœ… Enhanced Dashboard generated successfully!") print(f"šŸ“Š Dashboard Location: {dashboard_path.absolute()}") print(f"🌐 Open in browser: file://{dashboard_path.absolute()}") # Print summary statistics print(f"\nšŸ“ˆ Dashboard Summary:") print(f" Total Tests: {reporter.summary_stats['total']}") print(f" Passed: {reporter.summary_stats['passed']}") print(f" Failed: {reporter.summary_stats['failed']}") print(f" Skipped: {reporter.summary_stats['skipped']}") print(f" Success Rate: {reporter._calculate_success_rate():.1f}%") # Print feature highlights print(f"\nšŸŽÆ Dashboard Features:") print(f" ✨ Interactive video processing theme") print(f" šŸ“Š Real-time metrics and performance gauges") print(f" šŸ” Advanced filtering and search capabilities") print(f" šŸ“ˆ Dynamic charts and visualizations") print(f" šŸ“± Responsive design for all devices") print(f" šŸŽ¬ Cinema-inspired dark theme") print(f" šŸ“„ Export to PDF and CSV") print(f" šŸ”„ Real-time data refresh") print(f" ⚔ Zero external dependencies") return dashboard_path if __name__ == "__main__": try: dashboard_path = main() print(f"\nšŸš€ Ready to view your enhanced video processing dashboard!") print(f"Open: {dashboard_path.absolute()}") except Exception as e: print(f"āŒ Error generating dashboard: {e}") sys.exit(1)