KaraokeMerge/test_tool.py

70 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""
Simple test script to validate the Karaoke Song Library Cleanup Tool.
"""
import sys
import os
# Add the cli directory to the path
sys.path.append(os.path.join(os.path.dirname(__file__), 'cli'))
def test_basic_functionality():
"""Test basic functionality of the tool."""
print("Testing Karaoke Song Library Cleanup Tool...")
print("=" * 60)
try:
# Test imports
from utils import load_json_file, save_json_file
from matching import SongMatcher
from report import ReportGenerator
print("✅ All modules imported successfully")
# Test config loading
config = load_json_file('config/config.json')
print("✅ Configuration loaded successfully")
# Test song data loading (first few entries)
songs = load_json_file('data/allSongs.json')
print(f"✅ Song data loaded successfully ({len(songs):,} songs)")
# Test with a small sample
sample_songs = songs[:1000] # Test with first 1000 songs
print(f"Testing with sample of {len(sample_songs)} songs...")
# Initialize components
matcher = SongMatcher(config, data_dir)
reporter = ReportGenerator(config)
# Process sample
best_songs, skip_songs, stats = matcher.process_songs(sample_songs)
print(f"✅ Processing completed successfully")
print(f" - Total songs: {stats['total_songs']}")
print(f" - Unique songs: {stats['unique_songs']}")
print(f" - Duplicates found: {stats['duplicates_found']}")
# Test report generation
summary_report = reporter.generate_summary_report(stats)
print("✅ Report generation working")
print("\n" + "=" * 60)
print("🎉 All tests passed! The tool is ready to use.")
print("\nTo run the full analysis:")
print(" python cli/main.py")
print("\nTo run with verbose output:")
print(" python cli/main.py --verbose")
print("\nTo run a dry run (no skip list generated):")
print(" python cli/main.py --dry-run")
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
return False
return True
if __name__ == "__main__":
success = test_basic_functionality()
sys.exit(0 if success else 1)