def test_recoverRetraction_noRecoverExcluded(self): """Test _recoverRetraction with recoverExcluded=False.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) with mock.patch.object(unit, 'lastRetraction') as lastRetractionMock: unit.lastRetraction.recoverExcluded = False result = unit._recoverRetraction("G11", True) # pylint: disable=protected-access lastRetractionMock.generateRecoverCommands.assert_not_called() self.assertIsNone(unit.lastRetraction, "The lastRetraction should be set to None") self.assertEqual(result, ["G11"], "The result should contain one item")
def test_recoverRetraction_recoverExcluded(self): """Test _recoverRetraction with recoverExcluded=True.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) with mock.patch.object(unit, 'lastRetraction') as lastRetractionMock: unit.lastRetraction.recoverExcluded = True unit.lastRetraction.generateRecoverCommands.return_value = [ "recoverCommand" ] result = unit._recoverRetraction("G11", True) # pylint: disable=protected-access # The test against this mock covers both cases where returnCommands None and when it is # a list of commands since the final result is built from the generateRecoverCommands # result which is mocked anyway lastRetractionMock.generateRecoverCommands.assert_called_with( unit.position) self.assertIsNone(unit.lastRetraction, "The lastRetraction should be set to None") self.assertEqual(result, ["recoverCommand", "G11"], "The result should contain two items")