
import sys
import os
import asyncio

# Ensure we can import from src
sys.path.insert(0, os.path.join(os.getcwd(), "python", "src"))

try:
    from meta_client import MetaClient
    from advantage_plus import AdvantagePlusEngine
    from schemas import CreateCustomAudienceRequest
    import inspect
except ImportError as e:
    print(f"Import Error: {e}")
    sys.exit(1)

class MockClient(MetaClient):
    def __init__(self):
        pass

async def verify():
    print("Verifying Enhancements...")
    
    # 1. Verify Schema Update
    fields = CreateCustomAudienceRequest.model_fields
    if "is_eligible_for_sac_campaigns" in fields:
        print("[PASS] CreateCustomAudienceRequest has 'is_eligible_for_sac_campaigns'")
    else:
        print("[FAIL] CreateCustomAudienceRequest missing 'is_eligible_for_sac_campaigns'")
        
    # 2. Verify Advantage+ Update
    engine = AdvantagePlusEngine(MockClient())
    # Inspect arguments of the method? Or check code behavior?
    # We can inspect docstring or try to run it with mock (but it's async and complex).
    # Inspecting source line is better implies reading file, but here we imported it.
    # Let's inspect the code object using inspect source
    src = inspect.getsource(engine.create_advantage_shopping_campaign)
    if "is_adset_budget_sharing" in src:
        print("[PASS] AdvantagePlusEngine has 'is_adset_budget_sharing' logic")
    else:
        print("[FAIL] AdvantagePlusEngine missing 'is_adset_budget_sharing' logic")

    # 3. Verify New Modules Registration
    # We can inspect the registering logic or the __init__.py modules list?
    # Actually, let's see if we can import them from tools
    try:
        from tools import messaging, partnerships, experiments
        print("[PASS] New modules (messaging, partnerships, experiments) are importable from tools")
        
        # Check if they have get_tools
        if hasattr(messaging, 'get_tools') and hasattr(partnerships, 'get_tools') and hasattr(experiments, 'get_tools'):
             print("[PASS] New modules have get_tools()")
        else:
             print("[FAIL] New modules missing get_tools()")
             
    except ImportError as e:
        print(f"[FAIL] Could not import new modules from tools: {e}")

if __name__ == "__main__":
    asyncio.run(verify())
