Skip to content

Commit 5066ffa

Browse files
committed
Add FastAPI app with Docker, CI/CD, and linter
1 parent b3196b9 commit 5066ffa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/test_api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from unittest.mock import MagicMock, patch
44

55
# Add src to sys.path for imports
6-
sys.path.insert(0, os.path.abspath(os.path.join(
7-
os.path.dirname(__file__), '..', 'src')))
6+
sys.path.insert(
7+
0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src'))
8+
)
89

910
# --- Patch before importing app ---
1011
mock_model = MagicMock()
@@ -13,13 +14,13 @@
1314
patcher = patch('mlflow.sklearn.load_model', return_value=mock_model)
1415
patcher.start()
1516

16-
# Now import app
1717
from fastapi.testclient import TestClient
1818
from api.main import app
1919

20+
2021
client = TestClient(app)
2122

22-
# --- Test ---
23+
2324
def test_predict():
2425
sample_data = {
2526
"Recency": 1,
@@ -55,5 +56,6 @@ def test_predict():
5556
assert "risk_probability" in response.json()
5657
assert abs(response.json()["risk_probability"] - 0.7) < 1e-6
5758

59+
5860
# --- Cleanup ---
5961
patcher.stop()

0 commit comments

Comments
 (0)