def test_combine_combineNotAllowed_firmware(self): """Test the combine method with two firmware retractions when combine is not allowed.""" mockLogger = mock.Mock() unit = RetractionState( originalCommand="G10 S1", firmwareRetract=True ) unit.allowCombine = False toCombine = RetractionState( originalCommand="G10 S1", firmwareRetract=True ) result = unit.combine(toCombine, mockLogger) self.assertIs(result, unit, "The return value should be the unit instance") self.assertTrue(unit.firmwareRetract, "firmwareRetract should be True") self.assertIsNone(unit.extrusionAmount, "The extrusionAmount should not be modified") mockLogger.warn.assert_called()
def test_combine_combineNotAllowed_nonFirmware(self): """Test the combine method with two non-firmware retractions when combine is not allowed.""" mockLogger = mock.Mock() unit = RetractionState( originalCommand="G1 F100 E-1", firmwareRetract=False, extrusionAmount=1.0, feedRate=100.0 ) unit.allowCombine = False toCombine = RetractionState( originalCommand="G1 F200 E-0.5", firmwareRetract=False, extrusionAmount=0.5, feedRate=200.0 ) result = unit.combine(toCombine, mockLogger) self.assertIs(result, unit, "The return value should be the unit instance") self.assertEqual(unit.extrusionAmount, 1, "The extrusionAmount should not be modified") mockLogger.warn.assert_called()