# test_intelligence_pipeline.py
import asyncio
import pandas as pd
from ml.smart_detection import SmartAutoDetector

async def test_intelligence():
    # Create sample data
    source_df = pd.DataFrame({
        'company_name': ['Acme Corp', 'Tech Inc', 'Sales Co'],
        'contact_email': ['john@acme.com', 'jane@tech.com', 'bob@sales.com'],
        'revenue': [1000000, 2000000, 500000]
    })
    
    ref_df = pd.DataFrame({
        'organization': ['Acme Corporation', 'Technology Inc', 'Sales Company'],
        'email_address': ['j.smith@acme.com', 'jane@tech.com', 'robert@sales.com'],
        'annual_revenue': [1000000, 2100000, 500000]
    })
    
    # Test the detector directly
    detector = SmartAutoDetector()
    result = detector.detect_configuration(source_df, ref_df)
    
    print("✅ Detected Configuration:")
    print(f"  - Source ID: {result.source_id_col}")
    print(f"  - Mappings: {len(result.mappings)}")
    print(f"  - Blocking: {result.blocking_strategy}")
    
    # Verify mappings are intelligent
    assert any(m['source'] == 'company_name' and 'organization' in m['ref'] 
              for m in result.mappings), "Should map company_name to organization"
    
    print("\n🎉 Intelligence pipeline working!")

asyncio.run(test_intelligence())