Skip to content

Commit 2786465

Browse files
committed
Add FastAPI app with Docker, CI/CD, and linter checking flake8 and pytest
1 parent 1781b8d commit 2786465

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

test/test_api.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import os
44
import warnings
5+
56
warnings.filterwarnings("ignore", category=DeprecationWarning)
67

78
sys.path.insert(
@@ -22,40 +23,39 @@
2223
from fastapi.testclient import TestClient
2324
from api.main import app
2425

25-
client = TestClient(app)
26-
26+
client = TestClient(app)
2727

28-
def test_predict():
29-
sample_data = {
30-
"Recency": 1,
31-
"Frequency": 127,
32-
"Monetary": 489358,
33-
"Transaction_Hour": 8,
34-
"FraudResult": 0,
35-
"Average_Transaction_Amount": 2424.58,
36-
"Transaction_Day": 12,
37-
"ChannelId_ChannelId_2": False,
38-
"ChannelId_ChannelId_3": True,
39-
"ChannelId_ChannelId_5": False,
40-
"ProviderId_ProviderId_2": False,
41-
"ProviderId_ProviderId_3": False,
42-
"ProviderId_ProviderId_4": False,
43-
"ProviderId_ProviderId_5": False,
44-
"ProviderId_ProviderId_6": True,
45-
"PricingStrategy_1": False,
46-
"PricingStrategy_2": True,
47-
"PricingStrategy_4": False,
48-
"ProductCategory_data_bundles": False,
49-
"ProductCategory_financial_services": False,
50-
"ProductCategory_movies": False,
51-
"ProductCategory_other": False,
52-
"ProductCategory_ticket": False,
53-
"ProductCategory_transport": False,
54-
"ProductCategory_tv": False,
55-
"ProductCategory_utility_bill": False,
56-
}
28+
def test_predict():
29+
sample_data = {
30+
"Recency": 1,
31+
"Frequency": 127,
32+
"Monetary": 489358,
33+
"Transaction_Hour": 8,
34+
"FraudResult": 0,
35+
"Average_Transaction_Amount": 2424.58,
36+
"Transaction_Day": 12,
37+
"ChannelId_ChannelId_2": False,
38+
"ChannelId_ChannelId_3": True,
39+
"ChannelId_ChannelId_5": False,
40+
"ProviderId_ProviderId_2": False,
41+
"ProviderId_ProviderId_3": False,
42+
"ProviderId_ProviderId_4": False,
43+
"ProviderId_ProviderId_5": False,
44+
"ProviderId_ProviderId_6": True,
45+
"PricingStrategy_1": False,
46+
"PricingStrategy_2": True,
47+
"PricingStrategy_4": False,
48+
"ProductCategory_data_bundles": False,
49+
"ProductCategory_financial_services": False,
50+
"ProductCategory_movies": False,
51+
"ProductCategory_other": False,
52+
"ProductCategory_ticket": False,
53+
"ProductCategory_transport": False,
54+
"ProductCategory_tv": False,
55+
"ProductCategory_utility_bill": False,
56+
}
5757

58-
response = client.post("/predict", json=sample_data)
59-
assert response.status_code == 200
60-
assert "risk_probability" in response.json()
61-
assert abs(response.json()["risk_probability"] - 0.7) < 1e-6
58+
response = client.post("/predict", json=sample_data)
59+
assert response.status_code == 200
60+
assert "risk_probability" in response.json()
61+
assert abs(response.json()["risk_probability"] - 0.7) < 1e-6

0 commit comments

Comments
 (0)