feat: add remote device settings portal and Pi hot reload
- add /settings/device portal page and portal device-config GET endpoint - add portal navigation and client-side device settings editor UI - hot-reload Account/Car display config after local saves and server syncs - document portal workflow and Phase 25.5b completion - add runtime reload tests for account, car, and sync callback Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from modules import app_account, app_car, app_device_sync
|
||||
|
||||
|
||||
class RuntimeDeviceConfigReloadTest(unittest.TestCase):
|
||||
@patch.object(app_account.Account, "_load_config", return_value={})
|
||||
@patch("modules.app_device_config.get_device_config")
|
||||
def test_account_reload_runtime_config_uses_live_settings(
|
||||
self,
|
||||
get_device_config,
|
||||
_load_config,
|
||||
):
|
||||
account = app_account.Account()
|
||||
get_device_config.return_value = {
|
||||
"owner_name": "alice",
|
||||
"avatar_path": "img/alice.png",
|
||||
}
|
||||
|
||||
account.reload_runtime_config()
|
||||
|
||||
self.assertEqual(account.name, "alice")
|
||||
self.assertEqual(account.avatar_path, "img/alice.png")
|
||||
|
||||
@patch.object(app_car.Car, "_load_config", return_value={})
|
||||
@patch("modules.app_device_config.get_device_config")
|
||||
def test_car_reload_runtime_config_uses_live_settings(
|
||||
self,
|
||||
get_device_config,
|
||||
_load_config,
|
||||
):
|
||||
car = app_car.Car()
|
||||
get_device_config.return_value = {
|
||||
"car_model": "Corolla",
|
||||
"device_name": "Garage Pi",
|
||||
}
|
||||
|
||||
car.reload_runtime_config()
|
||||
|
||||
self.assertEqual(car.model, "Corolla")
|
||||
self.assertEqual(car.device_name, "Garage Pi")
|
||||
|
||||
|
||||
class DeviceSyncReloadCallbackTest(unittest.TestCase):
|
||||
def test_on_config_changed_calls_registered_callback(self):
|
||||
callback = Mock()
|
||||
original = app_device_sync._RELOAD_CALLBACK
|
||||
try:
|
||||
app_device_sync.register_reload_callback(callback)
|
||||
|
||||
app_device_sync._on_config_changed()
|
||||
|
||||
callback.assert_called_once_with()
|
||||
finally:
|
||||
app_device_sync._RELOAD_CALLBACK = original
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user