@@ -262,6 +262,36 @@ def test_shutdown(caplog):
262262 assert re .search (r"Telling node to shutdown" , caplog .text , re .MULTILINE )
263263
264264
265+ @pytest .mark .unit
266+ def test_factoryReset_config_uses_int_field ():
267+ """Test factoryReset(config) sets int32 protobuf field with an int value."""
268+ iface = MagicMock (autospec = MeshInterface )
269+ anode = Node (iface , 1234567890 , noProto = True )
270+
271+ amesg = admin_pb2 .AdminMessage ()
272+ with patch ("meshtastic.admin_pb2.AdminMessage" , return_value = amesg ):
273+ with patch .object (anode , "_sendAdmin" ) as mock_send_admin :
274+ anode .factoryReset (full = False )
275+
276+ assert amesg .factory_reset_config == 1
277+ mock_send_admin .assert_called_once_with (amesg , onResponse = anode .onAckNak )
278+
279+
280+ @pytest .mark .unit
281+ def test_factoryReset_full_sets_device_field ():
282+ """Test factoryReset(full=True) sets the full-device reset protobuf field."""
283+ iface = MagicMock (autospec = MeshInterface )
284+ anode = Node (iface , 1234567890 , noProto = True )
285+
286+ amesg = admin_pb2 .AdminMessage ()
287+ with patch ("meshtastic.admin_pb2.AdminMessage" , return_value = amesg ):
288+ with patch .object (anode , "_sendAdmin" ) as mock_send_admin :
289+ anode .factoryReset (full = True )
290+
291+ assert amesg .factory_reset_device is True
292+ mock_send_admin .assert_called_once_with (amesg , onResponse = anode .onAckNak )
293+
294+
265295@pytest .mark .unit
266296def test_setURL_empty_url (capsys ):
267297 """Test reboot"""
0 commit comments