StockDocs/test_implementation.py

43 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify the enhanced cache system implementation
"""
import json
import os
import datetime
from scraper.scraper import load_processed_cache, save_processed_cache, get_processing_progress
def test_cache_system():
"""Test the enhanced cache system"""
print("Testing enhanced cache system...")
# Test loading cache (should work even if file doesn't exist)
cache = load_processed_cache()
print(f"Initial cache loaded: {len(cache)} entries")
# Test saving cache
test_entry = {
"test_article_path": {
"processed_date": datetime.datetime.now().isoformat(),
"status": "completed",
"embedding_status": "pending",
"last_updated": datetime.datetime.now().isoformat()
}
}
save_processed_cache(test_entry)
print("Cache saved successfully")
# Test loading again
cache = load_processed_cache()
print(f"Cache loaded after save: {len(cache)} entries")
# Test progress tracking
progress = get_processing_progress()
print(f"Progress tracking: {progress}")
print("Cache system test completed successfully!")
if __name__ == "__main__":
test_cache_system()