diff --git a/README.md b/README.md index 9a5efbb..452995b 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ Possible options for testing: * To run just integration tests: pytest -mint * To run a smoke test with only one device connected serially: pytest -msmoke1 CAUTION: Running smoke1 will reset values on the device. + Be sure to hit the button on the device to reset after the test is run. * To run a specific test: pytest -msmoke1 meshtastic/test/test_smoke1.py::test_smoke1_info * To add another classification of tests, then look in pytest.ini * To see the unit test code coverage: pytest --cov=meshtastic diff --git a/bin/prerelease-tests.sh b/bin/prerelease-tests.sh index 6127792..27fe0a6 100755 --- a/bin/prerelease-tests.sh +++ b/bin/prerelease-tests.sh @@ -1,5 +1,7 @@ set -e +# You may consider running: "pytest -m smoke1" instead of this test. + echo "Running (crude) prerelease tests to verify sanity" echo running hello python3 tests/hello_world.py @@ -7,6 +9,7 @@ python3 tests/hello_world.py echo toggling router bin/run.sh --set is_router true bin/run.sh --set is_router false +# TODO: This does not seem to work. echo setting channel bin/run.sh --seturl "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ=" echo setting time diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 702c828..6247a32 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -628,7 +628,7 @@ def initParser(): "--set-owner", help="Set device owner name", action="store") parser.add_argument( - "--set-team", help="Set team affiliation (? for options)", action="store") + "--set-team", help="Set team affiliation (an invalid team will list valid values)", action="store") parser.add_argument( "--set-ham", help="Set licensed HAM ID and turn off encryption", action="store") diff --git a/meshtastic/test/test_smoke1.py b/meshtastic/test/test_smoke1.py index 3d2eea8..72290db 100644 --- a/meshtastic/test/test_smoke1.py +++ b/meshtastic/test/test_smoke1.py @@ -36,6 +36,15 @@ def test_smoke1_info(): assert return_value == 0 +@pytest.mark.smoke1 +def test_smoke1_debug(): + """Test --debug""" + return_value, out = subprocess.getstatusoutput('meshtastic --info --debug') + assert re.search(r'^Owner', out, re.MULTILINE) + assert re.search(r'^DEBUG:root', out, re.MULTILINE) + assert return_value == 0 + + @pytest.mark.smoke1 def test_smoke1_seriallog_to_file(): """Test --seriallog to a file creates a file""" @@ -168,6 +177,51 @@ def test_smoke1_set_owner(): assert return_value == 0 +@pytest.mark.smoke1 +def test_smoke1_set_team(): + """Test --set-team """ + # unset the team + return_value, out = subprocess.getstatusoutput('meshtastic --set-team CLEAR') + assert re.match(r'Connected to radio', out) + assert re.search(r'^Setting team to CLEAR', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(1) + return_value, out = subprocess.getstatusoutput('meshtastic --set-team CYAN') + assert re.search(r'Setting team to CYAN', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(1) + return_value, out = subprocess.getstatusoutput('meshtastic --info') + assert re.search(r'CYAN', out, re.MULTILINE) + assert return_value == 0 + + +@pytest.mark.smoke1 +def test_smoke1_ch_longslow_and_ch_shortfast(): + """Test --ch-longslow and --ch-shortfast""" + # unset the team + return_value, out = subprocess.getstatusoutput('meshtastic --ch-longslow') + assert re.match(r'Connected to radio', out) + assert re.search(r'Writing modified channels to device', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio (might reboot) + time.sleep(5) + return_value, out = subprocess.getstatusoutput('meshtastic --info') + assert re.search(r'Bw125Cr48Sf4096', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(1) + return_value, out = subprocess.getstatusoutput('meshtastic --ch-shortfast') + assert re.search(r'Writing modified channels to device', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio (might reboot) + time.sleep(5) + return_value, out = subprocess.getstatusoutput('meshtastic --info') + assert re.search(r'Bw500Cr45Sf128', out, re.MULTILINE) + assert return_value == 0 + + @pytest.mark.smoke1 def test_smoke1_ch_set_name(): """Test --ch-set name""" @@ -187,6 +241,34 @@ def test_smoke1_ch_set_name(): assert return_value == 0 +@pytest.mark.smoke1 +def test_smoke1_ch_add_and_ch_del(): + """Test --ch-add""" + return_value, out = subprocess.getstatusoutput('meshtastic --ch-add testing') + assert re.search(r'Writing modified channels to device', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(1) + return_value, out = subprocess.getstatusoutput('meshtastic --info') + assert re.match(r'Connected to radio', out) + assert re.search(r'SECONDARY', out, re.MULTILINE) + assert re.search(r'testing', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(1) + return_value, out = subprocess.getstatusoutput('meshtastic --ch-index 1 --ch-del') + assert re.search(r'Deleting channel 1', out, re.MULTILINE) + assert return_value == 0 + # pause for the radio + time.sleep(4) + # make sure the secondar channel is not there + return_value, out = subprocess.getstatusoutput('meshtastic --info') + assert re.match(r'Connected to radio', out) + assert not re.search(r'SECONDARY', out, re.MULTILINE) + assert not re.search(r'testing', out, re.MULTILINE) + assert return_value == 0 + + @pytest.mark.smoke1 def test_smoke1_ch_set_modem_config(): """Test --ch-set modem_config"""