From 428be9fbcea086ad723091426149498b9cde0b40 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Tue, 24 Jun 2025 11:16:23 -0700 Subject: [PATCH] add mesh_interface tests --- meshtastic/tests/test_mesh_interface.py | 35 ++++++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/meshtastic/tests/test_mesh_interface.py b/meshtastic/tests/test_mesh_interface.py index 65c0725..02a3d13 100644 --- a/meshtastic/tests/test_mesh_interface.py +++ b/meshtastic/tests/test_mesh_interface.py @@ -11,12 +11,12 @@ from ..protobuf import mesh_pb2, config_pb2 from .. import BROADCAST_ADDR, LOCAL_ADDR from ..mesh_interface import MeshInterface, _timeago from ..node import Node -try: - # Depends upon the powermon group, not installed by default - from ..slog import LogSet - from ..powermon import SimPowerSupply -except ImportError: - pytest.skip("Can't import LogSet or SimPowerSupply", allow_module_level=True) +# try: +# # Depends upon the powermon group, not installed by default +# from ..slog import LogSet +# from ..powermon import SimPowerSupply +# except ImportError: +# pytest.skip("Can't import LogSet or SimPowerSupply", allow_module_level=True) # TODO # from ..config import Config @@ -525,6 +525,28 @@ def test_getMyNodeInfo(): myinfo = iface.getMyNodeInfo() assert myinfo == anode +@pytest.mark.unit +@pytest.mark.usefixtures("reset_mt_config") +def test_getCannedMessage(): + """Test MeshInterface.getCannedMessage()""" + iface = MeshInterface(noProto=True) + node = MagicMock() + node.get_canned_message.return_value = "Hi|Bye|Yes" + iface.localNode = node + result = iface.getCannedMessage() + assert result == "Hi|Bye|Yes" + + +@pytest.mark.unit +@pytest.mark.usefixtures("reset_mt_config") +def test_getRingtone(): + """Test MeshInterface.getRingtone()""" + iface = MeshInterface(noProto=True) + node = MagicMock() + node.get_ringtone.return_value = "foo,bar" + iface.localNode = node + result = iface.getRingtone() + assert result == "foo,bar" @pytest.mark.unit @pytest.mark.usefixtures("reset_mt_config") @@ -543,7 +565,6 @@ def test_generatePacketId(capsys): assert err == "" assert pytest_wrapped_e.type == MeshInterface.MeshInterfaceError - @pytest.mark.unit @pytest.mark.usefixtures("reset_mt_config") def test_fixupPosition_empty_pos():