INITIAL COMMIT
This commit is contained in:
33
tests/test_repository.py
Normal file
33
tests/test_repository.py
Normal file
@ -0,0 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from garmin_coach_clone.config import DEFAULT_FIXED_TIMES, load_settings
|
||||
from garmin_coach_clone.db import Database
|
||||
from garmin_coach_clone.repository import Repository, ScheduleConfig, validate_schedule_config
|
||||
|
||||
|
||||
def test_schedule_restore_defaults(tmp_path, monkeypatch) -> None:
|
||||
monkeypatch.setenv("DATA_DIR", str(tmp_path))
|
||||
settings = load_settings()
|
||||
db = Database(tmp_path / "app.db")
|
||||
db.initialize()
|
||||
repo = Repository(db, settings)
|
||||
|
||||
restored = repo.restore_default_schedule()
|
||||
|
||||
assert restored.fixed_times == DEFAULT_FIXED_TIMES
|
||||
assert repo.schedule_config().active_window == "05:00-22:00"
|
||||
|
||||
|
||||
def test_schedule_validation_rejects_bad_window() -> None:
|
||||
with pytest.raises(ValueError, match="active window"):
|
||||
validate_schedule_config(
|
||||
ScheduleConfig(
|
||||
enabled=True,
|
||||
interval_minutes=30,
|
||||
active_window="22:00-05:00",
|
||||
fixed_times=["05:15"],
|
||||
days_ahead=1,
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user