Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ user_prefs:
send_owner_interval: 2
screen_on_secs: 31536000
wait_bluetooth_secs: 31536000
location_share: 'LocEnabled'
6 changes: 2 additions & 4 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions meshtastic/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 == ''


Expand Down