File size: 1,603 Bytes
6e128f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
🧪 Test Ziwei API locally
"""

import requests
import json

# Test data
test_request = {
    "birth_date": "2000-1-1",
    "birth_time": "14:30",
    "gender": "男",
    "is_leap_month": False,
    "fix_leap": True
}

print("🔮 Testing Ziwei API...")
print(f"Request: {json.dumps(test_request, ensure_ascii=False)}\n")

try:
    # Note: This test requires the API to be running
    # Run: uvicorn app:app --host 127.0.0.1 --port 8765
    response = requests.post(
        "http://127.0.0.1:8765/calculate-ziwei",
        json=test_request,
        timeout=10
    )

    if response.status_code == 200:
        result = response.json()
        print("✅ API Test Successful!\n")
        print(f"Status: {result['status']}")
        print(f"Solar Date: {result['data']['solar_date']}")
        print(f"Lunar Date: {result['data']['lunar_date']}")
        print(f"Sign: {result['data']['chart']['sign']}")
        print(f"Zodiac: {result['data']['chart']['zodiac']}")
        print(f"\n命宫: {result['data']['palaces'][3]['name']}")
        print(f"Major Stars: {', '.join(result['data']['palaces'][3]['major_stars'])}")
        print("\n🎯 All tests passed! ✨")
    else:
        print(f"❌ API returned status {response.status_code}")
        print(response.text)

except requests.exceptions.ConnectionError:
    print("⚠️  API not running. Please start with:")
    print("   cd /Volumes/sparksverse/huggingface-spaces/astrology-ziwei-api")
    print("   uvicorn app:app --host 127.0.0.1 --port 8765")
except Exception as e:
    print(f"❌ Test failed: {e}")