-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_endpoints.py
More file actions
47 lines (43 loc) · 1.38 KB
/
Copy pathtest_endpoints.py
File metadata and controls
47 lines (43 loc) · 1.38 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
import requests
import json
BASE_URL = "http://127.0.0.1:8000"
def test_predict():
print("Testing /predict endpoint...")
payload = {
"title": "Build a React Dashboard",
"description": "Create a responsive admin dashboard with charts",
"tags": ["frontend", "react", "charts"]
}
try:
response = requests.post(f"{BASE_URL}/predict", json=payload)
response.raise_for_status()
data = response.json()
print(f"Prediction successful: {data}")
return True
except Exception as e:
print(f"Prediction failed: {e}")
if response.text:
print(f"Response: {response.text}")
return False
def test_update():
print("\nTesting /update endpoint...")
payload = {
"title": "Build a React Dashboard",
"description": "Create a responsive admin dashboard with charts",
"tags": ["frontend", "react", "charts"],
"actual_cost": 500
}
try:
response = requests.post(f"{BASE_URL}/update", json=payload)
response.raise_for_status()
data = response.json()
print(f"Update successful: {data}")
return True
except Exception as e:
print(f"Update failed: {e}")
if response.text:
print(f"Response: {response.text}")
return False
if __name__ == "__main__":
if test_predict():
test_update()