def test_processPendingCommands_noPendingCommands_noExitScript(self): """Test _processPendingCommands if no pending commands and no exit script.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.pendingCommands = OrderedDict() unit.exitingExcludedRegionGcode = None result = unit._processPendingCommands() # pylint: disable=protected-access self.assertEqual(unit.pendingCommands, OrderedDict(), "The pendingCommands should be an empty dict") self.assertEqual(result, [], "The result should be an empty list.")
def test_processPendingCommands_withPendingCommands_noExitScript(self): """Test _processPendingCommands if pending commands exist and no exit script.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.pendingCommands["G1"] = { "X": 1, "Y": 2 } # Ensure dict is processed correctly unit.pendingCommands[ "G11"] = "G11 S1" # Ensure string is processed correctly unit.exitingExcludedRegionGcode = None result = unit._processPendingCommands() # pylint: disable=protected-access self.assertEqual(unit.pendingCommands, OrderedDict(), "The pendingCommands should be an empty dict") self.assertEqual( result, [AnyIn(["G1 X1 Y2", "G1 Y2 X1"]), "G11 S1"], "The result should contain the expected pending commands")
def test_processPendingCommands_withPendingCommands_withExitScript(self): """Test _processPendingCommands if pending commands exist and exit script is provided.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.pendingCommands["G1"] = { "X": 1.0, "Y": 2.0 } # Ensure dict is processed correctly unit.pendingCommands[ "G11"] = "G11 S1" # Ensure string is processed correctly unit.exitingExcludedRegionGcode = ["exitCommand"] result = unit._processPendingCommands() # pylint: disable=protected-access self.assertEqual(unit.pendingCommands, OrderedDict(), "The pendingCommands should be an empty dict") self.assertEqual( result, [ AnyIn(["G1 X%s Y%s" % (1.0, 2.0), "G1 Y%s X%s" % (2.0, 1.0)]), "G11 S1", "exitCommand" ], "The result should contain the expected pending commands plus the exit script" )