def test_processExtendedGcode_noGcode_notExcluding(self):
        """Test processExtendedGcode when not excluding and no gcode provided."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.object(
                unit, 'extendedExcludeGcodes') as mockExtendedExcludeGcodes:
            unit.excluding = False

            result = unit.processExtendedGcode("someCommand", None, None)

            mockExtendedExcludeGcodes.get.assert_not_called()
            self.assertIsNone(result, "The return value should be None")
    def test_processExtendedGcode_excluding_noMatch(self):
        """Test processExtendedGcode when excluding and no entry matches."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
                unit,
                extendedExcludeGcodes=mock.DEFAULT,
                _processExtendedGcodeEntry=mock.DEFAULT) as mocks:
            unit.excluding = True
            mocks["extendedExcludeGcodes"].get.return_value = None

            result = unit.processExtendedGcode("G1 X1 Y2", "G1", None)

            mocks["extendedExcludeGcodes"].get.assert_called_with("G1")
            mocks["_processExtendedGcodeEntry"].assert_not_called()
            self.assertIsNone(result, "The return value should be None")
    def test_processExtendedGcode_notExcluding_matchExists(self):
        """Test processExtendedGcode when not excluding and a matching entry exists."""
        mockLogger = mock.Mock()
        mockLogger.isEnabledFor.return_value = False  # For coverage of logging condition
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
                unit,
                extendedExcludeGcodes=mock.DEFAULT,
                _processExtendedGcodeEntry=mock.DEFAULT) as mocks:
            unit.excluding = False
            mockEntry = mock.Mock(name="entry")
            mockEntry.mode = "expectedMode"
            mocks["extendedExcludeGcodes"].get.return_value = mockEntry

            result = unit.processExtendedGcode(AnyIn(["G1 X1 Y2", "G1 Y2 X1"]),
                                               "G1", None)

            mocks["extendedExcludeGcodes"].get.assert_not_called()
            mocks["_processExtendedGcodeEntry"].assert_not_called()
            self.assertIsNone(result, "The return value should be None")
    def test_processExtendedGcode_excluding_matchExists(self):
        """Test processExtendedGcode when excluding and a matching entry exists."""
        mockLogger = mock.Mock()
        unit = ExcludeRegionState(mockLogger)

        with mock.patch.multiple(
                unit,
                extendedExcludeGcodes=mock.DEFAULT,
                _processExtendedGcodeEntry=mock.DEFAULT) as mocks:
            unit.excluding = True
            mockEntry = mock.Mock(name="entry")
            mockEntry.mode = "expectedMode"
            mocks["extendedExcludeGcodes"].get.return_value = mockEntry
            mocks["_processExtendedGcodeEntry"].return_value = "expectedResult"

            result = unit.processExtendedGcode("G1 X1 Y2", "G1", None)

            mocks["extendedExcludeGcodes"].get.assert_called_with("G1")
            mocks["_processExtendedGcodeEntry"].assert_called_with(
                "expectedMode", "G1 X1 Y2", "G1")
            self.assertEqual(
                result, "expectedResult",
                "The expected result of _processExtendedGcodeEntry should be returned"
            )