mirror of
https://github.com/meshtastic/python.git
synced 2026-01-18 12:48:03 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aff3bdd78e | ||
|
|
e9a8e26e76 | ||
|
|
83439679c1 |
@@ -117,6 +117,7 @@ def setPref(attributes, name, valStr):
|
|||||||
return
|
return
|
||||||
|
|
||||||
val = meshtastic.util.fromStr(valStr)
|
val = meshtastic.util.fromStr(valStr)
|
||||||
|
logging.debug(f'valStr:{valStr} val:{val}')
|
||||||
|
|
||||||
enumType = field.enum_type
|
enumType = field.enum_type
|
||||||
# pylint: disable=C0123
|
# pylint: disable=C0123
|
||||||
@@ -140,8 +141,11 @@ def setPref(attributes, name, valStr):
|
|||||||
for temp_name in sorted(names):
|
for temp_name in sorted(names):
|
||||||
print(f" {temp_name}")
|
print(f" {temp_name}")
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
setattr(attributes, snake_name, val)
|
setattr(attributes, snake_name, val)
|
||||||
|
except TypeError:
|
||||||
|
# The setter didn't like our arg type guess try again as a string
|
||||||
|
setattr(attributes, snake_name, valStr)
|
||||||
|
|
||||||
if Globals.getInstance().get_camel_case():
|
if Globals.getInstance().get_camel_case():
|
||||||
print(f"Set {camel_name} to {valStr}")
|
print(f"Set {camel_name} to {valStr}")
|
||||||
|
|||||||
@@ -803,6 +803,27 @@ def test_main_set_valid(capsys):
|
|||||||
mo.assert_called()
|
mo.assert_called()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
@pytest.mark.usefixtures("reset_globals")
|
||||||
|
def test_main_set_valid_wifi_passwd(capsys):
|
||||||
|
"""Test --set with valid field"""
|
||||||
|
sys.argv = ['', '--set', 'wifi_password', '123456789']
|
||||||
|
Globals.getInstance().set_args(sys.argv)
|
||||||
|
|
||||||
|
mocked_node = MagicMock(autospec=Node)
|
||||||
|
|
||||||
|
iface = MagicMock(autospec=SerialInterface)
|
||||||
|
iface.getNode.return_value = mocked_node
|
||||||
|
|
||||||
|
with patch('meshtastic.serial_interface.SerialInterface', return_value=iface) as mo:
|
||||||
|
main()
|
||||||
|
out, err = capsys.readouterr()
|
||||||
|
assert re.search(r'Connected to radio', out, re.MULTILINE)
|
||||||
|
assert re.search(r'Set wifi_password to 123456789', out, re.MULTILINE)
|
||||||
|
assert err == ''
|
||||||
|
mo.assert_called()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
@pytest.mark.usefixtures("reset_globals")
|
@pytest.mark.usefixtures("reset_globals")
|
||||||
def test_main_set_valid_camel_case(capsys):
|
def test_main_set_valid_camel_case(capsys):
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ def test_fromStr():
|
|||||||
assert fromStr('100.01') == 100.01
|
assert fromStr('100.01') == 100.01
|
||||||
assert fromStr('123') == 123
|
assert fromStr('123') == 123
|
||||||
assert fromStr('abc') == 'abc'
|
assert fromStr('abc') == 'abc'
|
||||||
|
assert fromStr('123456789') == 123456789
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unitslow
|
@pytest.mark.unitslow
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -12,7 +12,7 @@ with open("README.md", "r") as fh:
|
|||||||
# This call to setup() does all the work
|
# This call to setup() does all the work
|
||||||
setup(
|
setup(
|
||||||
name="meshtastic",
|
name="meshtastic",
|
||||||
version="1.2.55",
|
version="1.2.56",
|
||||||
description="Python API & client shell for talking to Meshtastic devices",
|
description="Python API & client shell for talking to Meshtastic devices",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|||||||
Reference in New Issue
Block a user