Files
spoopyghosty0--frameport/tests/test_battery.py
T
spoopyghosty0 627c05bf98 UI text: snooze for Later, Frame picker, clear labels, tr() everywhere, one vocabulary
- updates.snooze()/hidden(): the update banner's "Not now" hides a version for 24 h (update.snoozed); "Skip this version" unchanged
- Frame page: "Switch Frame…" opens a picker of remembered Frames (+ "Find another Frame…"); separate Disconnect button
- Labels: Update Steam art on Frame, Reset to suggested recipe… (asks first; pipeline.reset_recipe without the duplicated Rift branch), Uninstall from this PC…, Change program…, Share working recipe…, Force quit/End game…, ellipsis on everything that opens a dialog/picker or asks
- One Developer Mode path (Settings → System → Enable Developer Mode / Settings → Developer → Pair new host); linux_app help points to FEX
- tr() for the remaining visible strings (install status, job stages, update dialog, settings, files); this PC, recipe, program, for example, 50%, US spelling, Steam IDs, arm64
- Long callouts (live view, Type on Frame, pairing, library empty state) shortened, details in help texts
- tests/test_ui_text.py: untranslated literals, "..."/"e.g.", vocabulary, Switch Frame not wired to disconnect; snooze expiry test
2026-10-07 21:50:21 -04:00

41 lines
2.0 KiB
Python

from frameport.ui import battery as B
def bat(pct, plugged=False):
return {"percent": pct, "status": "Charging" if plugged else "Discharging", "plugged": plugged}
def test_warn_once_then_pause_then_resume_when_plugged_in():
assert B.advice(bat(80), True, None, False) is None
assert B.advice(bat(30), True, None, False) == "warn"
assert B.advice(bat(28), True, None, True) is None # warned already
assert B.advice(bat(15), True, None, True) == "pause"
assert B.advice(bat(14), True, "battery", True) is None # still low and unplugged: stay paused
assert B.advice(bat(14, plugged=True), True, "battery", True) == "resume"
assert B.advice(bat(25), True, "battery", True) == "resume"
def test_no_action_without_frame_work_or_while_charging_or_paused_for_another_reason():
assert B.advice(bat(5), False, None, False) is None
assert B.advice(bat(5, plugged=True), True, None, False) is None
assert B.advice(bat(5), True, "frame", False) is None # waiting for the Frame to come back: not ours
assert B.advice(bat(5), False, "battery", True) == "resume" # queue emptied (cancelled): don't stay paused
assert B.advice(None, True, "battery", True) == "resume" # no reading any more (old agent): don't block forever
assert B.advice(None, True, None, False) is None
def test_plugged_in_but_draining_counts_as_not_charging():
weak = {"percent": 12, "status": "Discharging", "plugged": True, "draining": True}
assert B.advice(weak, True, None, True) == "pause" and B.low(weak) and B.label(weak) == "12%"
def test_label():
assert B.label(bat(76)) == "76%" and B.label(bat(76, True)) == "76% ⚡" and B.label(None) == ""
assert B.low(bat(20)) and not B.low(bat(20, True)) and not B.low(bat(60))
def test_icon_follows_level_and_charging():
assert B.icon(bat(7, True)) == "BATTERY_CHARGING_FULL_ROUNDED"
assert B.icon(bat(7)) == "BATTERY_ALERT_ROUNDED" and B.icon(bat(100)) == "BATTERY_FULL_ROUNDED"
assert B.icon(bat(50)) == "BATTERY_3_BAR_ROUNDED" and B.icon(bat(90)) == "BATTERY_6_BAR_ROUNDED"