-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.py
More file actions
79 lines (65 loc) · 1.79 KB
/
test_api.py
File metadata and controls
79 lines (65 loc) · 1.79 KB
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
79
#!/usr/bin/env python3
"""
Test script for Tamil Panchang API
"""
import requests
import json
from datetime import date
API_BASE_URL = "http://localhost:8000"
def test_health():
"""Test health endpoint"""
print("Testing /health endpoint...")
response = requests.get(f"{API_BASE_URL}/health")
print(f"Status: {response.status_code}")
print(f"Response: {response.json()}")
print()
def test_panchang():
"""Test panchang endpoint"""
print("Testing /api/panchang endpoint...")
payload = {
"date": "2024-11-27",
"latitude": 10.7905, # Trichy
"longitude": 78.7047,
"timezone": 5.5
}
response = requests.post(
f"{API_BASE_URL}/api/panchang",
json=payload
)
print(f"Status: {response.status_code}")
print(f"Response:")
print(json.dumps(response.json(), indent=2))
print()
def test_today():
"""Test today endpoint"""
print("Testing /api/today endpoint...")
payload = {
"latitude": 13.0827, # Chennai
"longitude": 80.2707,
"timezone": 5.5
}
response = requests.post(
f"{API_BASE_URL}/api/today",
json=payload
)
print(f"Status: {response.status_code}")
print(f"Response:")
print(json.dumps(response.json(), indent=2))
print()
def main():
print("=" * 50)
print("Tamil Panchang API Tests")
print("=" * 50)
print()
try:
test_health()
test_panchang()
test_today()
print("✅ All tests passed!")
except requests.exceptions.ConnectionError:
print("❌ Error: Could not connect to API")
print("Make sure the API is running: docker-compose up -d")
except Exception as e:
print(f"❌ Error: {e}")
if __name__ == "__main__":
main()