@@ -494,6 +494,44 @@ def test_main_get_canned_messages(capsys, caplog, iface_with_nodes):
494494 assert err == ""
495495 mo .assert_called ()
496496
497+ @pytest .mark .unit
498+ @pytest .mark .usefixtures ("reset_mt_config" )
499+ def test_main_set_ringtone (capsys ):
500+ """Test --set-ringtone"""
501+ sys .argv = ["" , "--set-ringtone" , "foo,bar" ]
502+ mt_config .args = sys .argv
503+
504+ iface = MagicMock (autospec = SerialInterface )
505+ with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
506+ main ()
507+ out , err = capsys .readouterr ()
508+ assert re .search (r"Connected to radio" , out , re .MULTILINE )
509+ assert re .search (r"Setting ringtone to foo,bar" , out , re .MULTILINE )
510+ assert err == ""
511+ mo .assert_called ()
512+
513+ @pytest .mark .unit
514+ @pytest .mark .usefixtures ("reset_mt_config" )
515+ def test_main_get_ringtone (capsys , caplog , iface_with_nodes ):
516+ """Test --get-ringtone"""
517+ sys .argv = ["" , "--get-ringtone" ]
518+ mt_config .args = sys .argv
519+
520+ iface = iface_with_nodes
521+ iface .devPath = "bar"
522+
523+ mocked_node = MagicMock (autospec = Node )
524+ mocked_node .get_ringtone .return_value = "foo,bar"
525+ iface .localNode = mocked_node
526+
527+ with caplog .at_level (logging .DEBUG ):
528+ with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
529+ main ()
530+ out , err = capsys .readouterr ()
531+ assert re .search (r"Connected to radio" , out , re .MULTILINE )
532+ assert re .search (r"ringtone:foo,bar" , out , re .MULTILINE )
533+ assert err == ""
534+ mo .assert_called ()
497535
498536@pytest .mark .unit
499537@pytest .mark .usefixtures ("reset_mt_config" )
0 commit comments