forked from adriannylelis/stock-prediction-lstm-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api_predictions.py
More file actions
61 lines (52 loc) · 1.63 KB
/
test_api_predictions.py
File metadata and controls
61 lines (52 loc) · 1.63 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
"""Test API prediction with Production model."""
import json
import requests
API_URL = "http://localhost:5000"
print("\n" + "="*60)
print("Testing Stock Prediction API")
print("="*60)
# Test 1: Health check
print("\n1️⃣ Health Check")
print("-" * 60)
response = requests.get(f"{API_URL}/health")
print(f"Status: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
# Test 2: Model info
print("\n2️⃣ Model Info")
print("-" * 60)
response = requests.get(f"{API_URL}/model/info")
print(f"Status: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
# Test 3: Prediction for PETR4
print("\n3️⃣ Prediction - PETR4.SA")
print("-" * 60)
response = requests.post(
f"{API_URL}/predict",
json={"ticker": "PETR4.SA"},
headers={"Content-Type": "application/json"}
)
print(f"Status: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
# Test 4: Prediction for VALE3
print("\n4️⃣ Prediction - VALE3.SA")
print("-" * 60)
response = requests.post(
f"{API_URL}/predict",
json={"ticker": "VALE3.SA"},
headers={"Content-Type": "application/json"}
)
print(f"Status: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
# Test 5: Invalid ticker
print("\n5️⃣ Invalid Ticker Test")
print("-" * 60)
response = requests.post(
f"{API_URL}/predict",
json={"ticker": "INVALID"},
headers={"Content-Type": "application/json"}
)
print(f"Status: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
print("\n" + "="*60)
print("✅ API Tests Complete!")
print("="*60 + "\n")