Skip to content

Commit bf1eafc

Browse files
m4r1kopencode
andcommitted
fix(tui): remove legacy priority filter shim
Drop the internal priority_only compatibility argument from query_events_for_display so the new v5.3 event tier API has one explicit path: verbosity 0, 1, or 2. Also address CodeRabbit follow-ups by renaming ambiguous test comprehension variables and documenting the updated Stats E2E event-tier check. Co-Authored-By: opencode <noreply@opencode.ai>
1 parent 52af7d7 commit bf1eafc

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

docs/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ The numbered E2E tests are defined in `tests/e2e/groups/*.sh`. There are 36 numb
145145
| 28 | Stats | SQLite stats DB is created with samples and daemon-start event rows |
146146
| 29 | Stats | Stats writer failure is non-fatal and does not crash monitoring |
147147
| 30 | Stats | `monitor --once --graph` renders a graph from persisted stats data |
148-
| 31 | Stats | `monitor --once --events-only` reads events from SQLite |
148+
| 31 | Stats | `monitor --once --events-only` reads SQLite events and enforces event verbosity tiers |
149149
| 32 | Stats | Voltage nominal auto-detect re-snaps misreported NUT nominal voltage and records a silent event |
150150
| 33 | UPS Single | `voltage_sensitivity` avoids 120 V hot-grid false alarms while preserving real brownout detection |
151151
| 34 | Stats | Pending on-battery and restored notifications coalesce into one brief-outage summary |

src/eneru/tui.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ def query_events_for_display(
480480
*,
481481
max_events: Optional[int] = EVENTS_MAX_ROWS_NORMAL,
482482
verbosity: int = EVENTS_VERBOSITY_POWER,
483-
priority_only: Optional[bool] = None,
484483
grouped: bool = False,
485484
) -> List[str]:
486485
"""Pull events from each UPS's SQLite store, sorted by timestamp.
@@ -497,8 +496,7 @@ def query_events_for_display(
497496
should fall back to ``parse_log_events`` in that case.
498497
499498
``verbosity`` selects enabled tiers: ``0`` shows Power Events only,
500-
``1`` adds Diagnostics, and ``2`` adds Lifecycle. ``priority_only`` is
501-
accepted as a legacy shim for tests / older internal callers.
499+
``1`` adds Diagnostics, and ``2`` adds Lifecycle.
502500
503501
``max_events=None`` (or 0) disables the row cap entirely.
504502
@@ -507,10 +505,6 @@ def query_events_for_display(
507505
Lifecycle. Power events are never evicted; diagnostics outrank daemon
508506
lifecycle context when the cap is hit in verbose mode.
509507
"""
510-
if priority_only is not None:
511-
# Legacy compatibility: the old boolean API had priority_only=False
512-
# mean "show every event type".
513-
verbosity = EVENTS_VERBOSITY_POWER if priority_only else EVENTS_VERBOSITY_ALL
514508
verbosity = _events_verbosity(verbosity)
515509
multi_ups = config.multi_ups
516510
rows: List[tuple] = [] # (ts, label, event_type, detail)

tests/test_tui.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,10 +1636,10 @@ def test_events_only_flat_time_sorted_with_enabled_tiers(
16361636
@pytest.mark.unit
16371637
def test_snapshot_path_honours_verbose_level(self, tmp_path, capsys):
16381638
"""5.2.2 (cubic.dev / CodeRabbit P1): the non-events-only branch
1639-
of run_once also reads events for its tail block. Pre-fix it
1640-
used the default ``priority_only=True`` and silently ignored
1641-
``--verbose``, so diagnostics never surfaced even when the user
1642-
explicitly asked for them."""
1639+
of run_once also reads events for its tail block. Pre-fix it used
1640+
the default event query and silently ignored ``--verbose``, so
1641+
diagnostics never surfaced even when the user explicitly asked for
1642+
them."""
16431643
from eneru.tui import run_once
16441644
import time as _time
16451645
config = _events_config(tmp_path)
@@ -1703,7 +1703,7 @@ def test_events_only_length_caps_output(self, tmp_path, capsys):
17031703
run_once(config, events_only=True, length=5)
17041704
out = capsys.readouterr().out
17051705
# Should see exactly 5 lines -- the most-recent 5 ON_BATTERY rows.
1706-
lines = [l for l in out.splitlines() if "ON_BATTERY" in l]
1706+
lines = [line for line in out.splitlines() if "ON_BATTERY" in line]
17071707
assert len(lines) == 5
17081708
assert "row-49" in lines[-1]
17091709
assert "row-45" in lines[0]
@@ -1720,7 +1720,7 @@ def test_events_only_length_zero_means_no_cap(self, tmp_path, capsys):
17201720
])
17211721
run_once(config, events_only=True, length=0)
17221722
out = capsys.readouterr().out
1723-
lines = [l for l in out.splitlines() if "ON_BATTERY" in l]
1723+
lines = [line for line in out.splitlines() if "ON_BATTERY" in line]
17241724
assert len(lines) == 40, f"length=0 must show all rows; got {len(lines)}"
17251725

17261726

0 commit comments

Comments
 (0)