36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
from pathlib import Path
|
|
|
|
from mywhoosh_garmin_sync.config import Settings
|
|
|
|
|
|
def test_settings_from_env(monkeypatch, tmp_path):
|
|
monkeypatch.setenv("MYWHOOSH_EMAIL", "whoosh@example.com")
|
|
monkeypatch.setenv("MYWHOOSH_PASSWORD", "whoosh-pass")
|
|
monkeypatch.setenv("GARMIN_EMAIL", "garmin@example.com")
|
|
monkeypatch.setenv("GARMIN_PASSWORD", "garmin-pass")
|
|
monkeypatch.setenv("DATA_DIR", str(tmp_path))
|
|
monkeypatch.setenv("DRY_RUN", "true")
|
|
monkeypatch.setenv("POLL_INTERVAL_SECONDS", "123")
|
|
monkeypatch.setenv("TARGET_GARMIN_SERIAL_NUMBER", "123456")
|
|
monkeypatch.setenv("MYWHOOSH_MANUAL_LOGIN_WAIT_SECONDS", "900")
|
|
|
|
settings = Settings.from_env()
|
|
|
|
assert settings.data_dir == tmp_path
|
|
assert settings.raw_dir == tmp_path / "raw"
|
|
assert settings.dry_run is True
|
|
assert settings.poll_interval_seconds == 123
|
|
assert settings.dashboard_enabled is True
|
|
assert settings.dashboard_bind == "0.0.0.0"
|
|
assert settings.dashboard_port == 8080
|
|
assert settings.target_garmin_product_id == 3578
|
|
assert settings.target_garmin_serial_number == 123456
|
|
assert settings.mywhoosh_manual_login_wait_seconds == 900
|
|
assert settings.mywhoosh_activities_button_text == "ACTIVITIES"
|
|
assert settings.mywhoosh_download_button_selector == ".btnDownload"
|
|
assert settings.mywhoosh_auth_state_path == tmp_path / "mywhoosh_auth_state.json"
|
|
|
|
settings.ensure_directories()
|
|
assert Path(settings.raw_dir).is_dir()
|
|
assert Path(settings.mywhoosh_debug_dir).is_dir()
|