File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 33from 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 ---
1011mock_model = MagicMock ()
1314patcher = patch ('mlflow.sklearn.load_model' , return_value = mock_model )
1415patcher .start ()
1516
16- # Now import app
1717from fastapi .testclient import TestClient
1818from api .main import app
1919
20+
2021client = TestClient (app )
2122
22- # --- Test ---
23+
2324def 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 ---
5961patcher .stop ()
You can’t perform that action at this time.
0 commit comments