From f548d99776d7be468d2ce3492a2d8b7445b20111 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 8 Dec 2021 13:02:29 -0800 Subject: [PATCH] add set-ham and pos-fields tests --- meshtastic/__main__.py | 2 +- meshtastic/test/test_smoke1.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 68f7ab5..e0cc2b9 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -763,7 +763,7 @@ def initParser(): "--setlon", help="Set device longitude (allows use without GPS)") parser.add_argument( - "--pos-fields", help="Specify position message fields (? for more info)", + "--pos-fields", help="Specify position message fields. Use '0' for list of valid values. Can pass multiple values as a space separated list like this: '--pos-fields POS_ALTITUDE POS_ALT_MSL'", nargs="*", action="store") parser.add_argument("--debug", help="Show API library debug log messages", diff --git a/meshtastic/test/test_smoke1.py b/meshtastic/test/test_smoke1.py index 54fd5d3..dc0afae 100644 --- a/meshtastic/test/test_smoke1.py +++ b/meshtastic/test/test_smoke1.py @@ -48,6 +48,23 @@ def test_smoke1_sendping(): assert return_value == 0 +@pytest.mark.smoke1 +def test_smoke1_pos_fields(): + """Test --pos-fields (with some values POS_ALTITUDE POS_ALT_MSL POS_BATTERY)""" + return_value, out = subprocess.getstatusoutput('meshtastic --pos-fields POS_ALTITUDE POS_ALT_MSL POS_BATTERY') + assert re.match(r'Connected to radio', out) + assert re.search(r'^Setting position fields to 35', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(PAUSE_AFTER_COMMAND) + return_value, out = subprocess.getstatusoutput('meshtastic --pos-fields') + assert re.match(r'Connected to radio', out) + assert re.search(r'POS_ALTITUDE', out, re.MULTILINE) + assert re.search(r'POS_ALT_MSL', out, re.MULTILINE) + assert re.search(r'POS_BATTERY', out, re.MULTILINE) + assert return_value == 0 + + @pytest.mark.smoke1 def test_smoke1_test(): """Test --test @@ -367,6 +384,21 @@ def test_smoke1_configure(): assert re.search('^Writing modified preferences to device', out, re.MULTILINE) +@pytest.mark.smoke1 +def test_smoke1_set_ham(): + """Test --set-ham + Note: Do a factory reset after this setting so it is very short-lived. + """ + return_value, out = subprocess.getstatusoutput('meshtastic --set-ham KI1234') + assert re.search(r'Setting HAM ID', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(PAUSE_AFTER_REBOOT) + return_value, out = subprocess.getstatusoutput('meshtastic --info') + assert re.search(r'Owner: KI1234', out, re.MULTILINE) + assert return_value == 0 + + @pytest.mark.smoke1 def test_smoke1_factory_reset(): """Test factory reset"""