Dashboard eingefügt
This commit is contained in:
66
tests/test_dashboard.py
Normal file
66
tests/test_dashboard.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from mywhoosh_garmin_sync.dashboard import render_dashboard, render_health
|
||||
from mywhoosh_garmin_sync.state import ActivitySummary, SyncCheckSummary
|
||||
|
||||
|
||||
def test_dashboard_renders_latest_check_and_upload():
|
||||
html = render_dashboard(
|
||||
SyncCheckSummary(
|
||||
id=1,
|
||||
started_at="2026-05-07T10:00:00+00:00",
|
||||
finished_at="2026-05-07T10:01:00+00:00",
|
||||
status="ok",
|
||||
message="OK: processed 1 activity.",
|
||||
error_type=None,
|
||||
downloaded_count=1,
|
||||
processed_count=1,
|
||||
failed_count=0,
|
||||
),
|
||||
[
|
||||
ActivitySummary(
|
||||
source_ref="source-1",
|
||||
title="Morning Ride",
|
||||
source_url="https://example.test/ride.fit",
|
||||
converted_path="/data/converted/ride.fit",
|
||||
garmin_activity_id="12345",
|
||||
uploaded_at="2026-05-07T10:01:00+00:00",
|
||||
updated_at="2026-05-07T10:01:00+00:00",
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
assert "OK: processed 1 activity." in html
|
||||
assert "Morning Ride" in html
|
||||
assert "12345" in html
|
||||
assert "07.05.2026, 10:01 Uhr" in html
|
||||
assert "/data/converted/ride.fit" in html
|
||||
assert '<meta http-equiv="refresh" content="30">' in html
|
||||
|
||||
|
||||
def test_dashboard_renders_empty_state_before_first_check():
|
||||
html = render_dashboard(None, [])
|
||||
|
||||
assert "Never checked" in html
|
||||
assert "No sync check has finished yet." in html
|
||||
assert "No uploaded activities recorded yet." in html
|
||||
|
||||
|
||||
def test_health_renders_latest_status():
|
||||
body = render_health(
|
||||
SyncCheckSummary(
|
||||
id=1,
|
||||
started_at="2026-05-07T10:00:00+00:00",
|
||||
finished_at="2026-05-07T10:01:00+00:00",
|
||||
status="problem",
|
||||
message="Garmin requested MFA",
|
||||
error_type="garmin_login",
|
||||
downloaded_count=1,
|
||||
processed_count=1,
|
||||
failed_count=1,
|
||||
)
|
||||
)
|
||||
|
||||
assert body == (
|
||||
'{"status":"problem","message":"Garmin requested MFA",'
|
||||
'"error_type":"garmin_login",'
|
||||
'"finished_at":"2026-05-07T10:01:00+00:00"}'
|
||||
)
|
||||
Reference in New Issue
Block a user