Add matched training signals, daily recovery and performance analysis
This commit is contained in:
+30
-1
@@ -10,7 +10,36 @@ from garminconnect import GarminConnectAuthenticationError
|
||||
from app import create_app
|
||||
from app.extensions import db
|
||||
from app.models import GarminConnection, User
|
||||
from app.sync import run_due, session_lock
|
||||
from app.sync import cipher, run_due, session_lock
|
||||
|
||||
|
||||
def test_optional_recovery_failure_does_not_break_activity_sync(connected, monkeypatch):
|
||||
app, _client, _api, _sync = connected
|
||||
def failed_health(*_args):
|
||||
raise RuntimeError("PRIVATE-PROVIDER-RESPONSE")
|
||||
monkeypatch.setattr("app.recovery.sync_health", failed_health)
|
||||
with app.app_context():
|
||||
connection = db.session.scalar(db.select(GarminConnection))
|
||||
connection.health_enabled = True
|
||||
db.session.commit()
|
||||
assert run_due() == 1
|
||||
assert connection.failures == 0 and connection.last_success
|
||||
assert "Activity sync completed" in connection.health_message
|
||||
assert "PRIVATE-PROVIDER" not in connection.health_message
|
||||
|
||||
|
||||
def test_recovery_login_failure_preserves_encrypted_session(connected):
|
||||
app, _client, api, _sync = connected
|
||||
api.login.side_effect = RuntimeError("PRIVATE-LOGIN-RESPONSE")
|
||||
with app.app_context():
|
||||
original = db.session.scalar(db.select(GarminConnection)).tokens
|
||||
result = app.test_cli_runner().invoke(args=["backfill-health", "--email", "owner@example.test", "--days", "2"])
|
||||
assert result.exit_code == 1 and "PRIVATE-LOGIN" not in result.output
|
||||
with app.app_context():
|
||||
connection = db.session.scalar(db.select(GarminConnection))
|
||||
assert connection.tokens == original
|
||||
assert not connection.health_enabled
|
||||
assert cipher().decrypt(connection.tokens.encode())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user