fix: ruff findings
This commit is contained in:
+10
-15
@@ -8,7 +8,6 @@ Covers:
|
||||
- AC80-5: Theme roles for graph rendering
|
||||
- AC80-6: Headless interaction tests with temporary user config
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
@@ -21,15 +20,12 @@ sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
||||
|
||||
from fenris.store import init_store
|
||||
from fenris.preferences import (
|
||||
load_preferences,
|
||||
save_preferences,
|
||||
get_preference_path,
|
||||
)
|
||||
from fenris.themes import get_theme, get_graph_colors, THEME_NAMES
|
||||
from fenris.themes import get_graph_colors, THEME_NAMES
|
||||
from fenris.status_composition import (
|
||||
StatusState,
|
||||
compose_status,
|
||||
render_status_tui,
|
||||
)
|
||||
|
||||
|
||||
@@ -100,7 +96,7 @@ class TestPresetLoading:
|
||||
config_home = _make_prefs_dir(tmp_path)
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
# Theme should be fenris-amber
|
||||
assert app.theme == "fenris-chalktone"
|
||||
|
||||
@@ -113,7 +109,7 @@ class TestPresetLoading:
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
save_preferences(theme="nord", reduced_motion=False)
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
assert app.theme == "fenris-nord"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -125,20 +121,19 @@ class TestPresetLoading:
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
save_preferences(theme="high_contrast", reduced_motion=False)
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
assert app.theme == "fenris-high-contrast"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tui_applies_reduced_motion_from_prefs(self, tmp_path):
|
||||
"""TUI respects reduced_motion preference."""
|
||||
from fenris.tui import FenrisTuiApp
|
||||
from fenris.status_composition import compose_status
|
||||
|
||||
config_home = _make_prefs_dir(tmp_path)
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
save_preferences(theme="amber", reduced_motion=True)
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
# The app should have reduced_motion set
|
||||
assert app._reduced_motion is True
|
||||
|
||||
@@ -237,7 +232,7 @@ class TestPersistence:
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
# First run: change theme via preferences API
|
||||
app1 = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app1.run_test() as pilot:
|
||||
async with app1.run_test():
|
||||
save_preferences(theme="nord", reduced_motion=False)
|
||||
app1._current_theme_name = "nord"
|
||||
app1.theme = "fenris-nord"
|
||||
@@ -246,7 +241,7 @@ class TestPersistence:
|
||||
|
||||
# Second run: theme should persist
|
||||
app2 = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app2.run_test() as pilot:
|
||||
async with app2.run_test():
|
||||
assert app2.theme == theme_after
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -334,7 +329,7 @@ class TestReducedMotion:
|
||||
config_home = _make_prefs_dir(tmp_path)
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
# The app should check for reduced motion on mount
|
||||
assert hasattr(app, '_reduced_motion')
|
||||
|
||||
@@ -380,7 +375,7 @@ class TestSafePersistence:
|
||||
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
# TUI should start with default theme
|
||||
assert app.theme == "fenris-chalktone"
|
||||
# Dashboard should be functional
|
||||
@@ -399,7 +394,7 @@ class TestSafePersistence:
|
||||
|
||||
with patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}):
|
||||
app = FenrisTuiApp(store_path=tmp_path / "nonexistent.db")
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
# TUI should start without crash
|
||||
assert app.theme in ("fenris-chalktone", "fenris-amber", "fenris-nord", "fenris-high-contrast")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user