Merge branch 'dev'
Browse files- .github/workflows/CI_CD.yml +3 -1
- app/main.py +1 -1
- tests/test_functional.py +14 -0
.github/workflows/CI_CD.yml
CHANGED
|
@@ -27,6 +27,8 @@ jobs:
|
|
| 27 |
pip install -r requirements.txt
|
| 28 |
|
| 29 |
- name: Run tests
|
|
|
|
|
|
|
| 30 |
run: |
|
| 31 |
python -m pytest tests/ -v --cov=app --cov-report=term-missing
|
| 32 |
|
|
@@ -42,4 +44,4 @@ jobs:
|
|
| 42 |
- name: Push to Hub
|
| 43 |
env:
|
| 44 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 45 |
-
run: git push --force https://KLEB38:$HF_TOKEN@huggingface.co/spaces/KLEB38/OC_P5 main
|
|
|
|
| 27 |
pip install -r requirements.txt
|
| 28 |
|
| 29 |
- name: Run tests
|
| 30 |
+
env:
|
| 31 |
+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
| 32 |
run: |
|
| 33 |
python -m pytest tests/ -v --cov=app --cov-report=term-missing
|
| 34 |
|
|
|
|
| 44 |
- name: Push to Hub
|
| 45 |
env:
|
| 46 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 47 |
+
run: git push --force https://KLEB38:$HF_TOKEN@huggingface.co/spaces/KLEB38/OC_P5 main
|
app/main.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
import pandas as pd
|
| 3 |
import joblib
|
| 4 |
from app.schemas import EmployeeInput
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException
|
| 2 |
import pandas as pd
|
| 3 |
import joblib
|
| 4 |
from app.schemas import EmployeeInput
|
tests/test_functional.py
CHANGED
|
@@ -233,3 +233,17 @@ def test_logging(caplog):
|
|
| 233 |
assert response.status_code == 200 # l'API répond quand même
|
| 234 |
assert "Unknown value 'Logistique' for column 'departement'" in caplog.text
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
assert response.status_code == 200 # l'API répond quand même
|
| 234 |
assert "Unknown value 'Logistique' for column 'departement'" in caplog.text
|
| 235 |
|
| 236 |
+
def test_predict_by_id_valid():
|
| 237 |
+
|
| 238 |
+
response = client.get("/predict/1")
|
| 239 |
+
data=response.json()
|
| 240 |
+
|
| 241 |
+
assert response.status_code==200
|
| 242 |
+
assert "statut_employe" in data
|
| 243 |
+
assert "probability_score" in data
|
| 244 |
+
assert "top_5_factors" in data
|
| 245 |
+
|
| 246 |
+
def test_predict_by_id_not_found():
|
| 247 |
+
response = client.get("/predict/99999")
|
| 248 |
+
assert response.status_code == 404
|
| 249 |
+
assert response.json()["detail"] == "Employee ID not found in database"
|