mirror of
https://github.com/pdxlocations/contact.git
synced 2026-08-12 03:42:53 +02:00
Add log viewer functionality and enhance reconnect handling
- Introduced a log viewer in the UI to display live logs. - Added functionality to load the last few lines of the log file. - Enhanced reconnect logic to handle UI state during connection attempts. - Updated UI state management to track log viewer status. - Added tests for log loading functionality.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from argparse import Namespace
|
||||
from types import SimpleNamespace
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
@@ -9,13 +10,18 @@ class InterfacesTests(unittest.TestCase):
|
||||
def test_reconnect_interface_retries_until_connection_succeeds(self) -> None:
|
||||
args = Namespace()
|
||||
|
||||
with mock.patch("contact.utilities.interfaces.initialize_interface", side_effect=[None, None, "iface"]) as initialize:
|
||||
ready_interface = SimpleNamespace(localNode=SimpleNamespace(localConfig=object(), nodeNum=123))
|
||||
with mock.patch(
|
||||
"contact.utilities.interfaces.initialize_interface", side_effect=[None, None, ready_interface]
|
||||
) as initialize:
|
||||
with mock.patch("contact.utilities.interfaces.time.sleep") as sleep:
|
||||
result = reconnect_interface(args, attempts=3, delay_seconds=0.25)
|
||||
with mock.patch("contact.utilities.interfaces.logging.info") as info:
|
||||
result = reconnect_interface(args, attempts=3, delay_seconds=0.25)
|
||||
|
||||
self.assertEqual(result, "iface")
|
||||
self.assertIs(result, ready_interface)
|
||||
self.assertEqual(initialize.call_count, 3)
|
||||
self.assertEqual(sleep.call_count, 2)
|
||||
self.assertTrue(any("Reconnected to Meshtastic node" in call.args[0] for call in info.call_args_list))
|
||||
|
||||
def test_reconnect_interface_raises_after_exhausting_attempts(self) -> None:
|
||||
args = Namespace()
|
||||
|
||||
Reference in New Issue
Block a user