@@ -724,11 +724,66 @@ def test_main_sendtext_with_dest(mock_findPorts, mock_serial, mocked_open, mock_
724724 assert re .search (r"Warning: There were no self.nodes." , caplog .text , re .MULTILINE )
725725 assert err == ""
726726
727+ @pytest .mark .unit
728+ @pytest .mark .usefixtures ("reset_mt_config" )
729+ def test_main_removeposition_invalid (capsys ):
730+ """Test --remove-position with an invalid dest"""
731+ sys .argv = ["" , "--remove-position" , "--dest" , "!12345678" ]
732+ mt_config .args = sys .argv
733+ iface = MagicMock (autospec = SerialInterface )
734+ with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
735+ main ()
736+ out , err = capsys .readouterr ()
737+ assert re .search (r"Connected to radio" , out , re .MULTILINE )
738+ assert re .search (r"remote nodes is not supported" , out , re .MULTILINE )
739+ assert err == ""
740+ mo .assert_called ()
741+
742+ @pytest .mark .unit
743+ @pytest .mark .usefixtures ("reset_mt_config" )
744+ def test_main_setlat_invalid (capsys ):
745+ """Test --setlat with an invalid dest"""
746+ sys .argv = ["" , "--setlat" , "37.5" , "--dest" , "!12345678" ]
747+ mt_config .args = sys .argv
748+ iface = MagicMock (autospec = SerialInterface )
749+ with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
750+ main ()
751+ out , err = capsys .readouterr ()
752+ assert re .search (r"Connected to radio" , out , re .MULTILINE )
753+ assert re .search (r"remote nodes is not supported" , out , re .MULTILINE )
754+ assert err == ""
755+ mo .assert_called ()
756+
757+ @pytest .mark .unit
758+ @pytest .mark .usefixtures ("reset_mt_config" )
759+ def test_main_removeposition (capsys ):
760+ """Test --remove-position"""
761+ sys .argv = ["" , "--remove-position" ]
762+ mt_config .args = sys .argv
763+
764+ mocked_node = MagicMock (autospec = Node )
765+
766+ def mock_removeFixedPosition ():
767+ print ("inside mocked removeFixedPosition" )
768+
769+ mocked_node .removeFixedPosition .side_effect = mock_removeFixedPosition
770+
771+ iface = MagicMock (autospec = SerialInterface )
772+ iface .localNode = mocked_node
773+
774+ with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
775+ main ()
776+ out , err = capsys .readouterr ()
777+ assert re .search (r"Connected to radio" , out , re .MULTILINE )
778+ assert re .search (r"Removing fixed position" , out , re .MULTILINE )
779+ assert re .search (r"inside mocked removeFixedPosition" , out , re .MULTILINE )
780+ assert err == ""
781+ mo .assert_called ()
727782
728783@pytest .mark .unit
729784@pytest .mark .usefixtures ("reset_mt_config" )
730785def test_main_setlat (capsys ):
731- """Test --sendlat """
786+ """Test --setlat """
732787 sys .argv = ["" , "--setlat" , "37.5" ]
733788 mt_config .args = sys .argv
734789
0 commit comments