Final_Assignment / final_youtube_test.py
tonthatthienvu's picture
Clean repository without binary files
37cadfb
raw
history blame
2.27 kB
#!/usr/bin/env python3
"""
Final test for mocked YouTube video analysis with GAIA solver
"""
import os
import sys
import gaia_tools
from main import GAIASolver
from question_classifier import QuestionClassifier
# Original function reference
original_analyze_youtube_video = gaia_tools.analyze_youtube_video
# Mock implementation
def mock_analyze_youtube_video(video_url, question, max_frames=10):
"""Mock YouTube video analysis that returns predetermined response"""
print(f"🎬 Mock analyzing video: {video_url}")
return """
Video Analysis Results:
Video Title: Bird Identification Challenge: Backyard Birds in Spring
Duration: 3:42
Analysis:
After careful frame-by-frame analysis of the video, the highest number of different bird species visible simultaneously is 3.
This occurs at approximately 1:23 into the video, where we can see:
1. American Robin
2. Northern Cardinal
3. Blue Jay
These three species are clearly visible in the same frame at this timestamp.
"""
def main():
"""Run test with mocked YouTube analysis"""
# Set up mock
print("πŸ”„ Setting up mock YouTube analysis...")
gaia_tools.analyze_youtube_video = mock_analyze_youtube_video
try:
# Create GAIA solver
print("🧠 Creating GAIA solver...")
solver = GAIASolver()
# Create test question
question = {
'task_id': 'test-youtube-123',
'Question': 'In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?'
}
# Process question
print("🧩 Processing question...")
result = solver.solve_question(question)
# Display result
print("\nπŸ“‹ Result:")
print(result)
# Validate
if '3' in str(result):
print("βœ… Validation: CORRECT - Found expected answer '3'")
else:
print("❌ Validation: FAILED - Expected '3' but got different answer")
finally:
# Restore original function
print("\nπŸ”„ Restoring original YouTube analysis...")
gaia_tools.analyze_youtube_video = original_analyze_youtube_video
if __name__ == "__main__":
main()