Exemple #1
0
    def test_processExcludedMove_excluding_nonRetract(self):
        """Test _processExcludedMove with a non-retraction move and excluding=True."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)
        unit.excluding = True

        with mock.patch.multiple(unit,
                                 enterExcludedRegion=mock.DEFAULT,
                                 _processNonMove=mock.DEFAULT) as mocks:
            result = unit._processExcludedMove("G1 X10 Y20", 0)  # pylint: disable=protected-access

            mocks["enterExcludedRegion"].assert_not_called()
            mocks["_processNonMove"].assert_not_called()
            self.assertEqual(result, [], "The result should be an empty list")
Exemple #2
0
    def test_processExcludedMove_notExcluding_nonRetract(self):
        """Test _processExcludedMove with a non-retraction move and excluding=False."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)
        unit.excluding = False

        with mock.patch.multiple(unit,
                                 enterExcludedRegion=mock.DEFAULT,
                                 _processNonMove=mock.DEFAULT) as mocks:
            mocks["enterExcludedRegion"].return_value = ["enterExcludedRegion"]

            result = unit._processExcludedMove("G1 X10 Y20", 0)  # pylint: disable=protected-access

            mocks["enterExcludedRegion"].assert_called_with("G1 X10 Y20")
            mocks["_processNonMove"].assert_not_called()
            self.assertEqual(
                result, ["enterExcludedRegion"],
                "The result should be the commands returned by enterExcludedRegion"
            )
Exemple #3
0
    def test_processExcludedMove_notExcluding_retract(self):
        """Test _processExcludedMove with a retraction while moving and excluding=False."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)
        unit.excluding = False

        with mock.patch.multiple(unit,
                                 enterExcludedRegion=mock.DEFAULT,
                                 _processNonMove=mock.DEFAULT) as mocks:
            mocks["enterExcludedRegion"].return_value = ["enterExcludedRegion"]
            mocks["_processNonMove"].return_value = ["processNonMove"]

            result = unit._processExcludedMove("G1 X10 Y20", -1)  # pylint: disable=protected-access

            mocks["enterExcludedRegion"].assert_called_with("G1 X10 Y20")
            mocks["_processNonMove"].assert_called_with("G1 X10 Y20", -1)
            self.assertEqual(
                result, ["enterExcludedRegion", "processNonMove"],
                "The result should contain the expected commands")