From 9fac981ba6b2b3d843ccbb8a4c1328da642f5c45 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sat, 1 Jan 2022 14:53:57 -0800 Subject: [PATCH] test heartbeatTimer --- meshtastic/tests/test_mesh_interface.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/meshtastic/tests/test_mesh_interface.py b/meshtastic/tests/test_mesh_interface.py index b96f9e4..c0a0135 100644 --- a/meshtastic/tests/test_mesh_interface.py +++ b/meshtastic/tests/test_mesh_interface.py @@ -10,6 +10,7 @@ from ..mesh_interface import MeshInterface from ..node import Node from .. import mesh_pb2 from ..__init__ import LOCAL_ADDR, BROADCAST_ADDR +from ..radioconfig_pb2 import RadioConfig @pytest.mark.unit @@ -164,6 +165,22 @@ def test_sendPosition(reset_globals, caplog): assert re.search(r'p.time:', caplog.text, re.MULTILINE) +@pytest.mark.unit +def test_close_with_heartbeatTimer(reset_globals, caplog): + """Test close() with heartbeatTimer""" + iface = MeshInterface(noProto=True) + anode = Node('foo', 'bar') + radioConfig = RadioConfig() + radioConfig.preferences.phone_timeout_secs = 10 + anode.radioConfig = radioConfig + iface.localNode = anode + assert iface.heartbeatTimer is None + with caplog.at_level(logging.DEBUG): + iface._startHeartbeat() + assert iface.heartbeatTimer is not None + iface.close() + + @pytest.mark.unit def test_handleFromRadio_empty_payload(reset_globals, caplog): """Test _handleFromRadio"""