Harden main loop and store; by-id device default, BOARD_TZ
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
8649d3abd0
commit
44a1b3cf8c
7 files changed
+100
-30
No files matched your search
+16
-2
@@ -1,10 +1,10 @@
|
||||
import os
|
||||
import time as time_module
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import app
|
||||
import board
|
||||
from tests.helpers import FONT_DIR, load_timetables
|
||||
import store
|
||||
from tests.helpers import FONT_DIR, fixture_html, load_timetables
|
||||
|
||||
|
||||
def test_refresh_due_on_first_run():
|
||||
@@ -48,3 +48,17 @@ def test_board_image_renders_real_timetables(cz):
|
||||
fonts = board.load_fonts(FONT_DIR)
|
||||
img = app.board_image(load_timetables(), datetime(2026, 10, 6, 13, 28, 20), fonts, False, cz)
|
||||
assert img is not None and img.size == (480, 320)
|
||||
|
||||
|
||||
def test_load_cache_returns_parsed_timetables_and_fresh_flag(tmp_path):
|
||||
line4 = store.LineConfig("4", "Štípa,u potoka", "https://example.test/4")
|
||||
now = datetime(2026, 10, 6, 12, 0)
|
||||
store.refresh([line4], tmp_path, fetch=lambda url: fixture_html("line4_u_potoka.html"), now=now)
|
||||
timetables, stale = app.load_cache([line4], tmp_path, now, [], True)
|
||||
assert [t.line for t in timetables] == ["4"] and stale is False
|
||||
|
||||
|
||||
def test_load_cache_keeps_previous_values_on_error(tmp_path):
|
||||
previous = load_timetables()
|
||||
timetables, stale = app.load_cache(None, tmp_path, datetime(2026, 10, 6, 12, 0), previous, True)
|
||||
assert timetables is previous and stale is True
|
||||
Reference in new issue
Block a user