File size: 1,988 Bytes
2fbd0f4 |
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
#!/usr/bin/env python3
"""
Test script for the Tarot Space API
"""
import requests
import json
def test_tarot_api(space_url, card_name="The Fool", orientation="upright", question=""):
"""
Test the tarot API endpoint
"""
api_url = f"{space_url}/api/predict"
payload = {
"data": [card_name, orientation, question]
}
try:
response = requests.post(api_url, json=payload)
response.raise_for_status()
result = response.json()
return result
except requests.exceptions.RequestException as e:
return {"error": f"API request failed: {str(e)}"}
def main():
# Replace with your actual Space URL
space_url = "https://your-username-tarot-space.hf.space"
print("🔮 Testing Tarot API...")
print(f"Space URL: {space_url}")
print("-" * 50)
# Test cases
test_cases = [
{
"card_name": "The Fool",
"orientation": "upright",
"question": "What should I focus on in my career?"
},
{
"card_name": "The Magician",
"orientation": "upright",
"question": ""
},
{
"card_name": "The Lovers",
"orientation": "reversed",
"question": "What does this mean for my relationship?"
}
]
for i, test_case in enumerate(test_cases, 1):
print(f"\nTest {i}:")
print(f"Card: {test_case['card_name']}")
print(f"Orientation: {test_case['orientation']}")
print(f"Question: {test_case['question'] or 'None'}")
result = test_tarot_api(
space_url,
test_case['card_name'],
test_case['orientation'],
test_case['question']
)
if 'error' in result:
print(f"❌ Error: {result['error']}")
else:
print(f"✅ Response: {result.get('data', 'No data returned')}")
print("-" * 30)
if __name__ == "__main__":
main()
|