File size: 2,201 Bytes
6078432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import httpx
import asyncio
import json

async def test_live_api():
    print("🚀 Starte Live-API Test (100% reale Daten Check)...")
    
    url = "http://localhost:8000/search"
    params = {
        "cities": "Zandvoort",
        "checkin": "2026-03-15",
        "checkout": "2026-03-22",
        "adults": 4,
        "pets": 1
    }
    
    async with httpx.AsyncClient(timeout=120.0) as client:
        try:
            print(f"📡 Sende Anfrage an API: {url} für Zandvoort...")
            response = await client.get(url, params=params)
            
            if response.status_code != 200:
                print(f"❌ API Fehler: Status {response.status_code}")
                return

            data = response.json()
            deals = data.get("top_10_deals", [])
            
            print(f"✅ API Antwort erhalten. Gefundene Deals: {len(deals)}")
            
            if not deals:
                print("⚠️ Keine Deals gefunden. (Möglicherweise blockiert oder keine Verfügbarkeit)")
                return

            for i, deal in enumerate(deals[:3], 1):
                name = deal.get('name', 'Unbekannt')
                source = deal.get('source', 'Unbekannt')
                price = deal.get('price_per_night', 0)
                deal_url = deal.get('url', '')
                image_url = deal.get('image_url', '')

                print(f"\n--- Deal #{i}: {name} ---")
                print(f"   Quelle: {source}")
                print(f"   Preis: €{price}/Nacht")
                
                # Check URL
                if "booking.com" in deal_url or "airbnb.com" in deal_url:
                    print(f"   ✅ URL Valid: {deal_url[:60]}...")
                else:
                    print(f"   ❌ URL UNGÜLTIG: {deal_url}")

                # Check Image
                if image_url and image_url.startswith('http'):
                    print(f"   ✅ Bild-URL vorhanden: {image_url[:60]}...")
                else:
                    print(f"   ❌ Bild-URL FEHLT oder ist Platzhalter")

        except Exception as e:
            print(f"❌ Test fehlgeschlagen: {e}")

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