Major refactor of Ameba Control Panel v3.1.0: - Three-column layout: icon sidebar, config+history, log view - Dracula PRO theme with light/dark toggle - DTR/RTS GPIO control (replaces ASCII commands) - Multi-CDC firmware support for AmebaSmart control device - Dynamic DUT tabs with +/- management - NN Model flash image support - Settings dialog (Font, Serial, Flash, Command tabs) - Background port scanning, debounced session store - Adaptive log flush rate, format cache optimization - Smooth sidebar animation, deferred startup - pytest test framework with session/log/settings tests - Thread safety fixes: _alive guards, parented timers, safe baud parsing - Find highlight: needle-only highlighting with focused match color - Partial line buffering for table output - PyInstaller packaging with version stamp and module exclusions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from ameba_control_panel.services.settings_service import Settings
|
|
|
|
|
|
class TestSettings:
|
|
def test_defaults(self, tmp_path):
|
|
with patch("ameba_control_panel.services.settings_service.app_data_dir", return_value=tmp_path):
|
|
s = Settings()
|
|
assert s.font_size == 10
|
|
assert s.default_baud == 1_500_000
|
|
assert s.log_tail_lines == 100_000
|
|
assert s.port_scan_interval_sec == 5
|
|
assert s.partial_line_hold_ms == 300
|
|
|
|
def test_set_and_persist(self, tmp_path):
|
|
with patch("ameba_control_panel.services.settings_service.app_data_dir", return_value=tmp_path):
|
|
s = Settings()
|
|
s.font_size = 14
|
|
s.default_baud = 115200
|
|
s.save()
|
|
|
|
with patch("ameba_control_panel.services.settings_service.app_data_dir", return_value=tmp_path):
|
|
s2 = Settings()
|
|
assert s2.font_size == 14
|
|
assert s2.default_baud == 115200
|
|
|
|
def test_corrupt_file_uses_defaults(self, tmp_path):
|
|
(tmp_path / "settings.json").write_text("not json!", encoding="utf-8")
|
|
with patch("ameba_control_panel.services.settings_service.app_data_dir", return_value=tmp_path):
|
|
s = Settings()
|
|
assert s.font_size == 10
|