Download tests/test_features.py from PythonMindset/dakar-power-prediction: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/PythonMindset/dakar-power-prediction/resolve/554fba2d19809fb2be5bcf5eabe2aaa729eb2f15/tests/test_features.py
- Command line
-
hf download hf://spaces/PythonMindset/dakar-power-prediction@554fba2d19809fb2be5bcf5eabe2aaa729eb2f15/tests/test_features.py
-
curl -L -o test_features.py https://huggingface.co/spaces/PythonMindset/dakar-power-prediction/resolve/554fba2d19809fb2be5bcf5eabe2aaa729eb2f15/tests/test_features.py
1.03 kB
| import sys | |
| from pathlib import Path | |
| from datetime import datetime | |
| from unittest.mock import MagicMock | |
| # Mock streamlit avant tout import pour le CI headless | |
| sys.modules['streamlit'] = MagicMock() | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| from streamlit_app.utils_simple import create_time_features | |
| def test_create_time_features_keys(): | |
| result = create_time_features(datetime(2024, 6, 15, 14, 0)) | |
| assert set(result.keys()) == {'hour', 'day_of_week', 'month', 'saison', 'is_peak_hour'} | |
| def test_saison_juillet(): | |
| result = create_time_features(datetime(2024, 7, 1, 12, 0)) | |
| assert result['saison'] == 1 | |
| def test_saison_janvier(): | |
| result = create_time_features(datetime(2024, 1, 1, 12, 0)) | |
| assert result['saison'] == 0 | |
| def test_is_peak_hour_20h(): | |
| result = create_time_features(datetime(2024, 6, 15, 20, 0)) | |
| assert result['is_peak_hour'] == 1 | |
| def test_is_peak_hour_14h(): | |
| result = create_time_features(datetime(2024, 6, 15, 14, 0)) | |
| assert result['is_peak_hour'] == 0 | |