Final_Assignment / tests /test_loader.py
GAIA Developer
πŸ§ͺ Add comprehensive test infrastructure and async testing system
c262d1a
#!/usr/bin/env python3
"""
Test script for GAIAQuestionLoader
"""
from gaia_loader import GAIAQuestionLoader
def test_gaia_loader():
"""Test the GAIA question loader functionality"""
print("πŸ§ͺ Testing GAIAQuestionLoader")
print("=" * 50)
# Initialize loader
loader = GAIAQuestionLoader()
# Test basic functionality
print("\nπŸ“Š Loader Summary:")
summary = loader.summary()
for key, value in summary.items():
print(f" {key}: {value}")
# Test random question
print("\n🎲 Random Question:")
random_q = loader.get_random_question()
if random_q:
print(f" Task ID: {random_q['task_id']}")
print(f" Question: {random_q['question'][:100]}...")
print(f" Has file: {'Yes' if random_q.get('file_name') else 'No'}")
print(f" Level: {random_q.get('Level', 'Unknown')}")
# Test questions with files
print("\nπŸ“Ž Questions with Files:")
with_files = loader.get_questions_with_files()
print(f" Found {len(with_files)} questions with files")
for q in with_files[:3]: # Show first 3
print(f" - {q['task_id']}: {q.get('file_name', 'N/A')}")
# Test questions without files
print("\nπŸ“ Questions without Files:")
without_files = loader.get_questions_without_files()
print(f" Found {len(without_files)} questions without files")
for q in without_files[:3]: # Show first 3
print(f" - {q['task_id']}: {q['question'][:50]}...")
# Test by level
print("\nπŸ“ˆ Questions by Level:")
by_level = loader.count_by_level()
for level, count in by_level.items():
print(f" Level {level}: {count} questions")
# Show one example from each level
level_questions = loader.get_questions_by_level(level)
if level_questions:
example = level_questions[0]
print(f" Example: {example['question'][:60]}...")
# Test specific question lookup
print("\nπŸ” Test Question Lookup:")
if loader.questions:
test_id = loader.questions[0]['task_id']
found_q = loader.get_question_by_id(test_id)
if found_q:
print(f" βœ… Successfully found question by ID: {test_id}")
else:
print(f" ❌ Failed to find question by ID: {test_id}")
print("\nβœ… GAIAQuestionLoader test completed!")
if __name__ == "__main__":
test_gaia_loader()