Compare commits

..

3 Commits

Author SHA1 Message Date
mkinney
4955ab8df2 Update setup.py 2022-01-16 12:48:35 -08:00
mkinney
de39c98e50 Merge pull request #236 from mkinney/fix_enum_listing
fix enum listing; add tests for pref values
2022-01-16 12:47:49 -08:00
Mike Kinney
51378bb0eb fix enum listing; add tests for pref values 2022-01-16 12:45:28 -08:00
4 changed files with 26 additions and 5 deletions

View File

@@ -14,3 +14,4 @@ user_prefs:
send_owner_interval: 2
screen_on_secs: 31536000
wait_bluetooth_secs: 31536000
location_share: 'LocEnabled'

View File

@@ -134,10 +134,8 @@ def setPref(attributes, name, valStr):
print(f"Choices in sorted order are:")
names = []
for f in enumType.values:
tmp_name = f'{f.name}'
if Globals.getInstance().get_camel_case():
tmp_name = meshtastic.util.snake_to_camel(tmp_name)
names.append(name)
# Note: We must use the value of the enum (regardless if camel or snake case)
names.append(f'{f.name}')
for temp_name in sorted(names):
print(f" {temp_name}")
return

View File

@@ -893,6 +893,7 @@ def test_main_configure_with_snake_case(capsys):
assert re.search(r'Fixing altitude', out, re.MULTILINE)
assert re.search(r'Fixing latitude', out, re.MULTILINE)
assert re.search(r'Fixing longitude', out, re.MULTILINE)
assert re.search(r'Set location_share to LocEnabled', out, re.MULTILINE)
assert re.search(r'Writing modified preferences', out, re.MULTILINE)
assert err == ''
mo.assert_called()
@@ -1963,6 +1964,27 @@ def test_main_setPref_valid_field_invalid_enum(capsys, caplog):
setPref(prefs, 'charge_current', 'foo')
out, err = capsys.readouterr()
assert re.search(r'charge_current does not have an enum called foo', out, re.MULTILINE)
assert re.search(r'Choices in sorted order are', out, re.MULTILINE)
assert re.search(r'MA100', out, re.MULTILINE)
assert re.search(r'MA280', out, re.MULTILINE)
assert err == ''
@pytest.mark.unit
@pytest.mark.usefixtures("reset_globals")
def test_main_setPref_valid_field_invalid_enum_where_enums_are_camel_cased_values(capsys, caplog):
"""Test setPref() with a valid field but invalid enum value"""
radioConfig = RadioConfig()
prefs = radioConfig.preferences
with caplog.at_level(logging.DEBUG):
setPref(prefs, 'location_share', 'foo')
out, err = capsys.readouterr()
assert re.search(r'location_share does not have an enum called foo', out, re.MULTILINE)
assert re.search(r'Choices in sorted order are', out, re.MULTILINE)
assert re.search(r'LocDisabled', out, re.MULTILINE)
assert re.search(r'LocEnabled', out, re.MULTILINE)
assert err == ''

View File

@@ -12,7 +12,7 @@ with open("README.md", "r") as fh:
# This call to setup() does all the work
setup(
name="meshtastic",
version="1.2.56",
version="1.2.57",
description="Python API & client shell for talking to Meshtastic devices",
long_description=long_description,
long_description_content_type="text/markdown",