-
Notifications
You must be signed in to change notification settings - Fork 316
Update factory reset to use integer for config reset #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -262,6 +262,36 @@ def test_shutdown(caplog): | |||||
| assert re.search(r"Telling node to shutdown", caplog.text, re.MULTILINE) | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.unit | ||||||
| def test_factoryReset_config_uses_int_field(): | ||||||
| """Test factoryReset(config) sets int32 protobuf field with an int value.""" | ||||||
| iface = MagicMock(autospec=MeshInterface) | ||||||
| anode = Node(iface, 1234567890, noProto=True) | ||||||
|
|
||||||
| amesg = admin_pb2.AdminMessage() | ||||||
| with patch("meshtastic.admin_pb2.AdminMessage", return_value=amesg): | ||||||
| with patch.object(anode, "_sendAdmin") as mock_send_admin: | ||||||
| anode.factoryReset(full=False) | ||||||
|
|
||||||
| assert amesg.factory_reset_config == 1 | ||||||
| mock_send_admin.assert_called_once_with(amesg, onResponse=anode.onAckNak) | ||||||
|
Comment on lines
+271
to
+277
|
||||||
|
|
||||||
|
|
||||||
| @pytest.mark.unit | ||||||
| def test_factoryReset_full_sets_device_field(): | ||||||
| """Test factoryReset(full=True) sets the full-device reset protobuf field.""" | ||||||
| iface = MagicMock(autospec=MeshInterface) | ||||||
| anode = Node(iface, 1234567890, noProto=True) | ||||||
|
|
||||||
| amesg = admin_pb2.AdminMessage() | ||||||
| with patch("meshtastic.admin_pb2.AdminMessage", return_value=amesg): | ||||||
| with patch.object(anode, "_sendAdmin") as mock_send_admin: | ||||||
| anode.factoryReset(full=True) | ||||||
|
|
||||||
| assert amesg.factory_reset_device is True | ||||||
|
||||||
| assert amesg.factory_reset_device is True | |
| assert amesg.factory_reset_device == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
factory_reset_deviceis also an int32 field inAdminMessage(same asfactory_reset_config). Leaving it asTruewill likely still raise aTypeErrorunder newer protobuf runtimes that reject bools for int fields. Consider settingfactory_reset_deviceto anintvalue (e.g.,1) for consistency and to fully address the factory reset compatibility issue.