From 0261313fc592b498c4614fa297f65c6504d08f70 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Sun, 27 Jul 2025 12:10:05 -0700 Subject: [PATCH] add test --- meshtastic/tests/test_main.py | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/meshtastic/tests/test_main.py b/meshtastic/tests/test_main.py index 811c806..1e24dc2 100644 --- a/meshtastic/tests/test_main.py +++ b/meshtastic/tests/test_main.py @@ -18,6 +18,7 @@ from meshtastic.__main__ import ( onNode, onReceive, tunnelMain, + set_missing_flags_false, ) from meshtastic import mt_config @@ -1897,6 +1898,41 @@ position_flags: 35""" # mo.assert_called() +@pytest.mark.unit +def test_set_missing_flags_false(): + """Test set_missing_flags_false() function""" + config = { + "bluetooth": { + "enabled": True + }, + "lora": { + "txEnabled": True + } + } + + false_defaults = { + ("bluetooth", "enabled"), + ("lora", "sx126xRxBoostedGain"), + ("lora", "txEnabled"), + ("lora", "usePreset"), + ("position", "positionBroadcastSmartEnabled"), + ("security", "serialEnabled"), + ("mqtt", "encryptionEnabled"), + } + + set_missing_flags_false(config, false_defaults) + + # Preserved + assert config["bluetooth"]["enabled"] is True + assert config["lora"]["txEnabled"] is True + + # Added + assert config["lora"]["usePreset"] is False + assert config["lora"]["sx126xRxBoostedGain"] is False + assert config["position"]["positionBroadcastSmartEnabled"] is False + assert config["security"]["serialEnabled"] is False + assert config["mqtt"]["encryptionEnabled"] is False + @pytest.mark.unit @pytest.mark.usefixtures("reset_mt_config") def test_main_gpio_rd_no_gpio_channel(capsys):