mirror of
https://github.com/meshtastic/python.git
synced 2026-01-17 20:28:01 -05:00
add some config tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# example config using camelCase keys
|
||||
owner: Bob TBeam
|
||||
ownerShort: BOB
|
||||
|
||||
channelUrl: https://www.meshtastic.org/d/#CgUYAyIBAQ
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# example configuration file with snake_case keys
|
||||
owner: Bob TBeam
|
||||
owner_short: BOB
|
||||
|
||||
channel_url: https://www.meshtastic.org/d/#CgUYAyIBAQ
|
||||
|
||||
|
||||
@@ -341,6 +341,10 @@ def onConnected(interface):
|
||||
print(f"Setting device owner short to {configuration['owner_short']}")
|
||||
interface.getNode(args.dest).setOwner(long_name=None, short_owner=configuration['owner_short'])
|
||||
|
||||
if 'ownerShort' in configuration:
|
||||
print(f"Setting device owner short to {configuration['ownerShort']}")
|
||||
interface.getNode(args.dest).setOwner(long_name=None, short_owner=configuration['ownerShort'])
|
||||
|
||||
if 'channel_url' in configuration:
|
||||
print("Setting channel url to", configuration['channel_url'])
|
||||
interface.getNode(args.dest).setURL(configuration['channel_url'])
|
||||
|
||||
@@ -930,6 +930,7 @@ def test_main_configure_with_snake_case(capsys):
|
||||
out, err = capsys.readouterr()
|
||||
assert re.search(r'Connected to radio', out, re.MULTILINE)
|
||||
assert re.search(r'Setting device owner', out, re.MULTILINE)
|
||||
assert re.search(r'Setting device owner short', out, re.MULTILINE)
|
||||
assert re.search(r'Setting channel url', out, re.MULTILINE)
|
||||
assert re.search(r'Fixing altitude', out, re.MULTILINE)
|
||||
assert re.search(r'Fixing latitude', out, re.MULTILINE)
|
||||
@@ -957,6 +958,7 @@ def test_main_configure_with_camel_case_keys(capsys):
|
||||
out, err = capsys.readouterr()
|
||||
assert re.search(r'Connected to radio', out, re.MULTILINE)
|
||||
assert re.search(r'Setting device owner', out, re.MULTILINE)
|
||||
assert re.search(r'Setting device owner short', out, re.MULTILINE)
|
||||
assert re.search(r'Setting channel url', out, re.MULTILINE)
|
||||
assert re.search(r'Fixing altitude', out, re.MULTILINE)
|
||||
assert re.search(r'Fixing latitude', out, re.MULTILINE)
|
||||
@@ -1621,6 +1623,7 @@ def test_main_export_config(capsys):
|
||||
iface = MagicMock(autospec=SerialInterface)
|
||||
with patch('meshtastic.serial_interface.SerialInterface', return_value=iface) as mo:
|
||||
mo.getLongName.return_value = 'foo'
|
||||
mo.getShortName.return_value = 'oof'
|
||||
mo.localNode.getURL.return_value = 'bar'
|
||||
mo.getMyNodeInfo().get.return_value = { 'latitudeI': 1100000000, 'longitudeI': 1200000000,
|
||||
'altitude': 100, 'batteryLevel': 34, 'latitude': 110.0,
|
||||
@@ -1637,6 +1640,7 @@ position_flags: 35"""
|
||||
assert not re.search(r'Connected to radio', out, re.MULTILINE)
|
||||
|
||||
assert re.search(r'owner: foo', out, re.MULTILINE)
|
||||
assert re.search(r'owner_short: oof', out, re.MULTILINE)
|
||||
assert re.search(r'channel_url: bar', out, re.MULTILINE)
|
||||
assert re.search(r'location:', out, re.MULTILINE)
|
||||
assert re.search(r'lat: 110.0', out, re.MULTILINE)
|
||||
|
||||
Reference in New Issue
Block a user