Add project infrastructure and core application files
Add .gitignore, GitLab CI pipeline with test/lint/build/release stages, project documentation (README, LICENSE, CHANGELOG, CONTRIBUTING, SECURITY), PyInstaller packaging configuration with icon and version info, Python project configuration with dependencies, and complete application source including battery provider, device discovery, settings management, UI components, startup control, and comprehensive test suite
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
|
||||
from logitech_battery_widget.config import AppConfig, ConfigStore
|
||||
|
||||
|
||||
def test_config_round_trip(tmp_path):
|
||||
path = tmp_path / "config.json"
|
||||
store = ConfigStore(path)
|
||||
expected = AppConfig(theme="dark", always_on_top=True, window_x=12, window_y=34)
|
||||
|
||||
store.save(expected)
|
||||
|
||||
assert store.load() == expected
|
||||
assert json.loads(path.read_text(encoding="utf-8"))["theme"] == "dark"
|
||||
|
||||
|
||||
def test_invalid_config_uses_safe_values(tmp_path):
|
||||
path = tmp_path / "config.json"
|
||||
path.write_text('{"theme": "purple", "refresh_interval_seconds": 1}', encoding="utf-8")
|
||||
|
||||
loaded = ConfigStore(path).load()
|
||||
|
||||
assert loaded.theme == "system"
|
||||
assert loaded.refresh_interval_seconds == 15
|
||||
|
||||
|
||||
def test_broken_json_returns_defaults(tmp_path):
|
||||
path = tmp_path / "config.json"
|
||||
path.write_text("not json", encoding="utf-8")
|
||||
assert ConfigStore(path).load() == AppConfig()
|
||||
Reference in New Issue
Block a user