# test_new_categorization.py
"""
Test script to verify the new categorization logic
"""
from activity_categorizer import ActivityCategorizer

def test_categorization():
    categorizer = ActivityCategorizer()
    
    # Test cases based on user requirements
    test_cases = [
        # Browser category - should only be YouTube, Gmail, and searches
        ("YouTube - Google Chrome", "chrome.exe", "browser"),
        ("Gmail - Inbox - Google Chrome", "chrome.exe", "browser"),
        ("Google Search: python tutorial", "chrome.exe", "browser"),
        ("youtube.com - Watching tutorial", "chrome.exe", "browser"),
        
        # Productive category - AI assistants and development tools
        ("claude.ai - Claude", "chrome.exe", "productive"),
        ("ChatGPT", "chrome.exe", "productive"),
        ("Stack Overflow - Python question", "chrome.exe", "productive"),
        ("cPanel - Web Hosting Control Panel", "chrome.exe", "productive"),
        ("FileZilla - FTP Client", "filezilla.exe", "productive"),
        ("localhost:3000 - React App", "chrome.exe", "productive"),
        ("main.py - Visual Studio Code", "code.exe", "productive"),
        ("GitHub - Repository", "chrome.exe", "productive"),
        ("phpMyAdmin - Database", "chrome.exe", "productive"),
        
        # Non-work category
        ("Facebook", "chrome.exe", "non-work"),
        ("Netflix", "chrome.exe", "non-work"),
        ("Instagram", "chrome.exe", "non-work"),
        ("Windows Default Lock Screen", "LockApp.exe", "non-work"),
        
        # Server category
        ("AWS Management Console", "chrome.exe", "server"),
        ("Azure Portal", "chrome.exe", "server"),
        
        # Edge cases - general browsing should go to browser
        ("Random Website - Google Chrome", "chrome.exe", "browser"),
        ("News Site - Chrome", "chrome.exe", "browser"),
    ]
    
    print("Testing New Categorization Logic")
    print("=" * 80)
    print(f"{'Title':<45} {'App':<15} {'Expected':<12} {'Actual':<12} {'Status':<10}")
    print("-" * 80)
    
    passed = 0
    failed = 0
    
    for title, app, expected in test_cases:
        category_info = categorizer.get_detailed_category(title, app)
        actual = category_info['category']
        status = "✓ PASS" if actual == expected else "✗ FAIL"
        
        if actual == expected:
            passed += 1
        else:
            failed += 1
            
        # Truncate title for display
        display_title = title[:42] + "..." if len(title) > 45 else title
        
        print(f"{display_title:<45} {app:<15} {expected:<12} {actual:<12} {status:<10}")
    
    print("-" * 80)
    print(f"Results: {passed} passed, {failed} failed")
    
    # Additional detailed test for activities from your screenshot
    print("\n\nDetailed Test for Your Screenshot Activities:")
    print("=" * 80)
    
    screenshot_activities = [
        ("general (1140 activities) · Unknown, chrome.exe, pycharm64.exe", "chrome.exe"),
        ("Windows Default Lock Screen (137 activities) · LockApp.exe", "LockApp.exe"),
        ("Timesheet App (93 activities) · chrome.exe", "chrome.exe"),
        ("First Economy Mail (166 activities) · chrome.exe", "chrome.exe"),
        ("Claude (92 activities) · claude.exe", "claude.exe"),
        ("eel (29 activities) · chrome.exe", "chrome.exe"),
        ("WAAREE Admin (102 activities) · chrome.exe", "chrome.exe"),
    ]
    
    for activity, app in screenshot_activities:
        category_info = categorizer.get_detailed_category(activity, app)
        print(f"\nActivity: {activity}")
        print(f"App: {app}")
        print(f"Category: {category_info['category']}")
        print(f"Subcategory: {category_info['subcategory']}")
        print(f"Confidence: {category_info['confidence']}")
        print("-" * 40)

if __name__ == "__main__":
    test_categorization()
