import requests import json BASE_URL = "http://localhost:8000" def test_brand_features(): print("Testing Brand Portal API...") # 1. Ensure Data Seeded requests.post(f"{BASE_URL}/monetization/seed") # 2. Mock Login (Resolve Name to ID) # Since we can't fully simulate the frontend Logic here easily, we'll manually pick ID 2 (Nike) # The frontend logic finds ID 2 for "Nike". BRAND_ID = 2 print(f"\n1. Accessing Brand Dashboard for ID {BRAND_ID} (Nike)...") try: res = requests.get(f"{BASE_URL}/brand/{BRAND_ID}/dashboard") if res.status_code == 200: data = res.json() print(f"✅ Brand Name: {data['brand_name']}") print(f"✅ Total Clicks: {data['total_clicks']}") print(f"✅ GMV Generated: ${data['gmv_generated']}") print(f"✅ Active Products: {data['product_count']}") if data['products']: print(f" Top SKU: {data['products'][0]['name']}") else: print(f"❌ Failed to load dashboard: {res.status_code}") except Exception as e: print(f"❌ Connection failed: {e}") # 3. Test Brand Feed print(f"\n2. Fetching Brand Feed...") try: res = requests.get(f"{BASE_URL}/brand/{BRAND_ID}/feed") feed = res.json() print(f"✅ Feed Items: {len(feed)}") except Exception as e: print(f"❌ Connection failed: {e}") if __name__ == "__main__": test_brand_features()