Spaces:
Sleeping
Sleeping
Download tests/test_learning_progress_service.py from Kentlo/cert-study-app: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/Kentlo/cert-study-app/resolve/main/tests/test_learning_progress_service.py
- Command line
-
hf download hf://spaces/Kentlo/cert-study-app/tests/test_learning_progress_service.py
-
curl -L -o test_learning_progress_service.py https://huggingface.co/spaces/Kentlo/cert-study-app/resolve/main/tests/test_learning_progress_service.py
1.08 kB
| from datetime import date | |
| from cert_study_app.services import learning_progress_service as progress_service | |
| def test_learning_progress_migrates_legacy_daily_key(tmp_path, monkeypatch): | |
| progress_path = tmp_path / "learning_progress.json" | |
| progress_path.write_text( | |
| '{"daily": {"2026-06-21": {"tracks": {"linux": {"steps": ["lesson"], "counts": {"lesson": 1}}}}}}', | |
| encoding="utf-8", | |
| ) | |
| monkeypatch.setattr(progress_service, "PROGRESS_PATH", progress_path) | |
| assert progress_service.completed_steps("linux", date(2026, 6, 21)) == {"lesson"} | |
| assert progress_service.study_units("linux", date(2026, 6, 21)) == 0.3 | |
| def test_learning_progress_writes_activity_key(tmp_path, monkeypatch): | |
| progress_path = tmp_path / "learning_progress.json" | |
| monkeypatch.setattr(progress_service, "PROGRESS_PATH", progress_path) | |
| progress_service.record_activity("linux", "practice", amount=1, target_date=date(2026, 6, 21)) | |
| payload = progress_path.read_text(encoding="utf-8") | |
| assert '"activity"' in payload | |
| assert '"daily"' not in payload | |