#!/usr/bin/env python3
"""Test direct access to each account."""

import sys
sys.path.insert(0, '/Users/dominiquezhoumacmini/Library/Python/3.9/lib/python/site-packages')

from google.ads.googleads.client import GoogleAdsClient

# All visible accounts
ACCOUNTS = [
    ("FR_EU", "7441745274"),
    ("US_OLD", "7480586470"),
    ("Unknown_MCC?", "4380090021"),
]

def test_account(client, name, customer_id):
    """Test basic query on account."""
    ga_service = client.get_service("GoogleAdsService")
    
    # Simple query
    query = """
        SELECT customer.id, customer.descriptive_name
        FROM customer
        LIMIT 1
    """
    
    print(f"\nTesting {name} ({customer_id})...")
    
    try:
        response = ga_service.search(customer_id=customer_id, query=query)
        for row in response:
            print(f"  ✅ SUCCESS: {row.customer.descriptive_name}")
        return True
    except Exception as e:
        error_msg = str(e)
        if "USER_PERMISSION_DENIED" in error_msg:
            print(f"  ❌ Permission denied")
        else:
            print(f"  ❌ Error: {error_msg[:100]}")
        return False

def main():
    client = GoogleAdsClient.load_from_storage("/Users/dominiquezhoumacmini/.google-ads.yaml")
    
    print("Testing direct access to all accounts (no MCC login)...\n")
    
    for name, cid in ACCOUNTS:
        test_account(client, name, cid)

if __name__ == "__main__":
    main()
