@@ -734,28 +734,22 @@ def test_main_setlat(capsys):
734734
735735 mocked_node = MagicMock (autospec = Node )
736736
737- def mock_writeConfig ():
738- print ("inside mocked writeConfig" )
737+ def mock_setFixedPosition (lat , lon , alt ):
738+ print ("inside mocked setFixedPosition" )
739+ print (f"{ lat } { lon } { alt } " )
739740
740- mocked_node .writeConfig .side_effect = mock_writeConfig
741+ mocked_node .setFixedPosition .side_effect = mock_setFixedPosition
741742
742743 iface = MagicMock (autospec = SerialInterface )
743-
744- def mock_sendPosition (lat , lon , alt ):
745- print ("inside mocked sendPosition" )
746- print (f"{ lat } { lon } { alt } " )
747-
748- iface .sendPosition .side_effect = mock_sendPosition
749- iface .localNode .return_value = mocked_node
744+ iface .localNode = mocked_node
750745
751746 with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
752747 main ()
753748 out , err = capsys .readouterr ()
754749 assert re .search (r"Connected to radio" , out , re .MULTILINE )
755750 assert re .search (r"Fixing latitude" , out , re .MULTILINE )
756751 assert re .search (r"Setting device position" , out , re .MULTILINE )
757- assert re .search (r"inside mocked sendPosition" , out , re .MULTILINE )
758- # TODO: Why does this not work? assert re.search(r'inside mocked writeConfig', out, re.MULTILINE)
752+ assert re .search (r"inside mocked setFixedPosition" , out , re .MULTILINE )
759753 assert err == ""
760754 mo .assert_called ()
761755
@@ -769,28 +763,22 @@ def test_main_setlon(capsys):
769763
770764 mocked_node = MagicMock (autospec = Node )
771765
772- def mock_writeConfig ():
773- print ("inside mocked writeConfig" )
766+ def mock_setFixedPosition (lat , lon , alt ):
767+ print ("inside mocked setFixedPosition" )
768+ print (f"{ lat } { lon } { alt } " )
774769
775- mocked_node .writeConfig .side_effect = mock_writeConfig
770+ mocked_node .setFixedPosition .side_effect = mock_setFixedPosition
776771
777772 iface = MagicMock (autospec = SerialInterface )
778-
779- def mock_sendPosition (lat , lon , alt ):
780- print ("inside mocked sendPosition" )
781- print (f"{ lat } { lon } { alt } " )
782-
783- iface .sendPosition .side_effect = mock_sendPosition
784- iface .localNode .return_value = mocked_node
773+ iface .localNode = mocked_node
785774
786775 with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
787776 main ()
788777 out , err = capsys .readouterr ()
789778 assert re .search (r"Connected to radio" , out , re .MULTILINE )
790779 assert re .search (r"Fixing longitude" , out , re .MULTILINE )
791780 assert re .search (r"Setting device position" , out , re .MULTILINE )
792- assert re .search (r"inside mocked sendPosition" , out , re .MULTILINE )
793- # TODO: Why does this not work? assert re.search(r'inside mocked writeConfig', out, re.MULTILINE)
781+ assert re .search (r"inside mocked setFixedPosition" , out , re .MULTILINE )
794782 assert err == ""
795783 mo .assert_called ()
796784
@@ -804,28 +792,22 @@ def test_main_setalt(capsys):
804792
805793 mocked_node = MagicMock (autospec = Node )
806794
807- def mock_writeConfig ():
808- print ("inside mocked writeConfig" )
795+ def mock_setFixedPosition (lat , lon , alt ):
796+ print ("inside mocked setFixedPosition" )
797+ print (f"{ lat } { lon } { alt } " )
809798
810- mocked_node .writeConfig .side_effect = mock_writeConfig
799+ mocked_node .setFixedPosition .side_effect = mock_setFixedPosition
811800
812801 iface = MagicMock (autospec = SerialInterface )
813-
814- def mock_sendPosition (lat , lon , alt ):
815- print ("inside mocked sendPosition" )
816- print (f"{ lat } { lon } { alt } " )
817-
818- iface .sendPosition .side_effect = mock_sendPosition
819- iface .localNode .return_value = mocked_node
802+ iface .localNode = mocked_node
820803
821804 with patch ("meshtastic.serial_interface.SerialInterface" , return_value = iface ) as mo :
822805 main ()
823806 out , err = capsys .readouterr ()
824807 assert re .search (r"Connected to radio" , out , re .MULTILINE )
825808 assert re .search (r"Fixing altitude" , out , re .MULTILINE )
826809 assert re .search (r"Setting device position" , out , re .MULTILINE )
827- assert re .search (r"inside mocked sendPosition" , out , re .MULTILINE )
828- # TODO: Why does this not work? assert re.search(r'inside mocked writeConfig', out, re.MULTILINE)
810+ assert re .search (r"inside mocked setFixedPosition" , out , re .MULTILINE )
829811 assert err == ""
830812 mo .assert_called ()
831813
0 commit comments