fix: ruff findings
This commit is contained in:
+13
-21
@@ -13,29 +13,22 @@ import sqlite3
|
||||
from xml.etree import ElementTree
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
||||
|
||||
from textual.app import App
|
||||
from textual.pilot import Pilot
|
||||
|
||||
from fenris.store import init_store, SCHEMA_VERSION
|
||||
from fenris.monitoring_periods import ensure_period_open, close_period
|
||||
from fenris.store import init_store
|
||||
from fenris.monitoring_periods import ensure_period_open
|
||||
from fenris.projection import (
|
||||
ConfidenceState,
|
||||
compute_projection,
|
||||
DISCLOSURES,
|
||||
WARMING_MIN_DAYS,
|
||||
STALENESS_HOURS,
|
||||
YOUNG_REGIME_DAYS,
|
||||
)
|
||||
from fenris.status import (
|
||||
FRESH_THRESHOLD_S,
|
||||
STALENESS_THRESHOLD_S,
|
||||
grade_freshness,
|
||||
)
|
||||
from fenris.tui import (
|
||||
@@ -45,7 +38,6 @@ from fenris.tui import (
|
||||
_query_drive_health,
|
||||
_query_daily_graph_data,
|
||||
_query_hourly_graph_data,
|
||||
_RANGE_OPTIONS,
|
||||
_RANGE_DEFAULT,
|
||||
_MIN_WIDTH,
|
||||
_MIN_HEIGHT,
|
||||
@@ -283,7 +275,7 @@ class TestDenseScreen:
|
||||
conn.close()
|
||||
|
||||
app = FenrisTuiApp(store_path=tmp_path / "test.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
assert app.query_one("#headline-band") is not None
|
||||
assert app.query_one("#usage-history") is not None
|
||||
assert app.query_one("#drive-health") is not None
|
||||
@@ -303,7 +295,7 @@ class TestDenseScreen:
|
||||
conn.close()
|
||||
|
||||
app = FenrisTuiApp(store_path=tmp_path / "test.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
headline = str(app.query_one("#headline-band").render())
|
||||
assert "remaining" in headline.lower() or "projection" in headline.lower()
|
||||
|
||||
@@ -321,7 +313,7 @@ class TestDenseScreen:
|
||||
conn.close()
|
||||
|
||||
app = FenrisTuiApp(store_path=tmp_path / "test.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
headline = str(app.query_one("#headline-band").render())
|
||||
assert "projection confidence" in headline.lower()
|
||||
# Contributing facts shown, never a percentage as confidence
|
||||
@@ -343,7 +335,7 @@ class TestDenseScreen:
|
||||
conn.close()
|
||||
|
||||
app = FenrisTuiApp(store_path=tmp_path / "test.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
strip = str(app.query_one("#service-strip").render())
|
||||
assert "Boot:" in strip
|
||||
assert "Timer:" in strip
|
||||
@@ -484,7 +476,7 @@ class TestDenseScreen:
|
||||
auth_notice = "Open with fenris (no sudo). Actions authenticate via polkit. ? Help"
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
headline = str(app.query_one("#headline-band").render())
|
||||
str(app.query_one("#headline-band").render())
|
||||
# Identity now shows Fenris by Bongbetic (issue #79)
|
||||
assert "Fenris by Bongbetic" in str(app.query_one("#identity").render())
|
||||
assert auth_notice in str(app.query_one("#auth-notice").render())
|
||||
@@ -526,7 +518,7 @@ class TestDisclosuresAndGreeting:
|
||||
async def test_empty_store_greeting(self, tmp_path):
|
||||
"""Empty store shows 'no observations yet' with enable hint."""
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
headline = str(app.query_one("#headline-band").render())
|
||||
assert "no observations yet" in headline.lower()
|
||||
assert "enable" in headline.lower() or "resume" in headline.lower()
|
||||
@@ -591,9 +583,9 @@ class TestFirstRun:
|
||||
async def test_first_run_prompt(self, tmp_path):
|
||||
"""First-run prompt makes the keyboard action and boot effect explicit."""
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
headline = str(app.query_one("#headline-band").render())
|
||||
strip = str(app.query_one("#service-strip").render())
|
||||
str(app.query_one("#service-strip").render())
|
||||
assert "no observations yet" in headline.lower()
|
||||
assert "r resume — enable monitoring and future boots" in headline.lower()
|
||||
assert "r resume" in str(app.query_one("#action-rail").render()).lower()
|
||||
@@ -866,7 +858,7 @@ class TestQueryHourlyGraphData:
|
||||
class TestHistoryGraph:
|
||||
def test_empty_data(self, tmp_path):
|
||||
"""Empty data shows awaiting message."""
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
# We test the widget directly via the app's compose
|
||||
graph = HistoryGraph()
|
||||
# Simulate setting empty data
|
||||
@@ -1129,7 +1121,7 @@ class TestBarGraphTUI:
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test(size=(80, 24)) as pilot:
|
||||
await pilot.press("v", "v")
|
||||
graph = app.query_one("#usage-history")
|
||||
app.query_one("#usage-history")
|
||||
assert app.query_one("#activity-panel").border_title == "Drive activity"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user