cheikhaidev-ui Claude Sonnet 4.6 commited on
Commit ·
f121cdb
1
Parent(s): 3566034
test(ci): add test_features.py to CI pipeline and fix stale assertions
Browse files- Add tests/test_features.py to pytest run in ci.yml
- Fix test_saison_juillet: expected value 1 → 2 (saison des pluies)
- Add test_saison_avril: covers saison sèche chaude (→ 1)
- Add test_is_peak_hour_8h: covers morning peak (7-9h) added in last fix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- .github/workflows/ci.yml +1 -1
- tests/test_features.py +14 -0
.github/workflows/ci.yml
CHANGED
|
@@ -24,4 +24,4 @@ jobs:
|
|
| 24 |
pip install pytest pandas numpy scikit-learn lightgbm streamlit plotly
|
| 25 |
|
| 26 |
- name: Run tests
|
| 27 |
-
run: python -m pytest tests/test_config.py -v
|
|
|
|
| 24 |
pip install pytest pandas numpy scikit-learn lightgbm streamlit plotly
|
| 25 |
|
| 26 |
- name: Run tests
|
| 27 |
+
run: python -m pytest tests/test_config.py tests/test_features.py -v
|
tests/test_features.py
CHANGED
|
@@ -17,11 +17,19 @@ def test_create_time_features_keys():
|
|
| 17 |
|
| 18 |
|
| 19 |
def test_saison_juillet():
|
|
|
|
| 20 |
result = create_time_features(datetime(2024, 7, 1, 12, 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
assert result['saison'] == 1
|
| 22 |
|
| 23 |
|
| 24 |
def test_saison_janvier():
|
|
|
|
| 25 |
result = create_time_features(datetime(2024, 1, 1, 12, 0))
|
| 26 |
assert result['saison'] == 0
|
| 27 |
|
|
@@ -31,6 +39,12 @@ def test_is_peak_hour_20h():
|
|
| 31 |
assert result['is_peak_hour'] == 1
|
| 32 |
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def test_is_peak_hour_14h():
|
| 35 |
result = create_time_features(datetime(2024, 6, 15, 14, 0))
|
| 36 |
assert result['is_peak_hour'] == 0
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def test_saison_juillet():
|
| 20 |
+
# Juillet → saison des pluies (Jun-Oct) → 2
|
| 21 |
result = create_time_features(datetime(2024, 7, 1, 12, 0))
|
| 22 |
+
assert result['saison'] == 2
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def test_saison_avril():
|
| 26 |
+
# Avril → saison sèche chaude (Mar-Mai) → 1
|
| 27 |
+
result = create_time_features(datetime(2024, 4, 1, 12, 0))
|
| 28 |
assert result['saison'] == 1
|
| 29 |
|
| 30 |
|
| 31 |
def test_saison_janvier():
|
| 32 |
+
# Janvier → saison sèche fraîche (Nov-Fév) → 0
|
| 33 |
result = create_time_features(datetime(2024, 1, 1, 12, 0))
|
| 34 |
assert result['saison'] == 0
|
| 35 |
|
|
|
|
| 39 |
assert result['is_peak_hour'] == 1
|
| 40 |
|
| 41 |
|
| 42 |
+
def test_is_peak_hour_8h():
|
| 43 |
+
# Pic matin 7-9h
|
| 44 |
+
result = create_time_features(datetime(2024, 6, 15, 8, 0))
|
| 45 |
+
assert result['is_peak_hour'] == 1
|
| 46 |
+
|
| 47 |
+
|
| 48 |
def test_is_peak_hour_14h():
|
| 49 |
result = create_time_features(datetime(2024, 6, 15, 14, 0))
|
| 50 |
assert result['is_peak_hour'] == 0
|