#!/usr/bin/env python3
"""
Test the find_artist_mbid method.
"""

import sys
import os
sys.path.append('/app/src')

# Add the src directory to Python path
sys.path.insert(0, '/app/src')

def test_find_artist():
    """Test the find_artist_mbid method."""
    print("🔍 Testing find_artist_mbid method...")
    
    try:
        # Import the cleaner
        from cli.main import MusicBrainzCleaner
        
        # Initialize cleaner
        cleaner = MusicBrainzCleaner(use_database=True)
        
        # Test with AC/DC
        print("1. Testing find_artist_mbid with 'AC/DC'...")
        artist_mbid = cleaner.find_artist_mbid('AC/DC')
        print(f"   Result: {artist_mbid}")
        print(f"   Type: {type(artist_mbid)}")
        
        if artist_mbid:
            print(f"   Is string: {isinstance(artist_mbid, str)}")
            print(f"   Length: {len(artist_mbid)}")
            
            # Test if we can call .lower() on it
            try:
                lower_mbid = artist_mbid.lower()
                print(f"   Lower: {lower_mbid}")
            except Exception as e:
                print(f"   Error calling .lower(): {e}")
        
        # Test with a collaboration
        print("\n2. Testing find_artist_mbid with 'Afrojack ft. Chris Brown'...")
        collab_mbid = cleaner.find_artist_mbid('Afrojack ft. Chris Brown')
        print(f"   Result: {collab_mbid}")
        print(f"   Type: {type(collab_mbid)}")
        
        if collab_mbid:
            print(f"   Is string: {isinstance(collab_mbid, str)}")
            
            # Test if we can call .lower() on it
            try:
                lower_mbid = collab_mbid.lower()
                print(f"   Lower: {lower_mbid}")
            except Exception as e:
                print(f"   Error calling .lower(): {e}")
        
    except Exception as e:
        print(f"❌ Error: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    test_find_artist() 