mirror of
https://github.com/meshtastic/python.git
synced 2026-01-16 03:37:57 -05:00
add main unit test for --seturl
This commit is contained in:
@@ -732,7 +732,7 @@ def initParser():
|
||||
"--setlon", help="Set device longitude (allows use without GPS)")
|
||||
|
||||
parser.add_argument(
|
||||
"--pos-fields", help="Specify position message fields. Use '0' for list of valid values. "\
|
||||
"--pos-fields", help="Specify fields to send when sending a position. Use no argument for a 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")
|
||||
|
||||
@@ -604,3 +604,24 @@ def test_main_set_team_invalid(capsys):
|
||||
assert err == ''
|
||||
mo.assert_called()
|
||||
mm.Value.assert_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_main_seturl(capsys):
|
||||
"""Test --seturl (url used below is what is generated after a factory_reset)"""
|
||||
sys.argv = ['', '--seturl', 'https://www.meshtastic.org/d/#CgUYAyIBAQ']
|
||||
args = sys.argv
|
||||
parser = None
|
||||
parser = argparse.ArgumentParser()
|
||||
our_globals = Globals.getInstance()
|
||||
our_globals.set_parser(parser)
|
||||
our_globals.set_args(args)
|
||||
iface = MagicMock(autospec=SerialInterface)
|
||||
with patch('meshtastic.serial_interface.SerialInterface', return_value=iface) as mo:
|
||||
main()
|
||||
out, err = capsys.readouterr()
|
||||
print('out:', out)
|
||||
print('err:', err)
|
||||
assert re.search(r'Connected to radio', out, re.MULTILINE)
|
||||
assert err == ''
|
||||
mo.assert_called()
|
||||
|
||||
Reference in New Issue
Block a user