def test_extruderTriggers_OnExtrudingStart(self): self.Extruder.reset() state = ExtruderState() self.Extruder.add_state(state) # test OnExtrudingStart - True Filter triggers = ExtruderTriggers(True, None, None, None, None, None, None, None, None, None) # test True with true filter state.IsExtrudingStart = True state.IsPrimed = False # turn this off so we don't have to account for this default state self.assertTrue(self.Extruder.is_triggered(triggers)) # test False with True filter state.IsExtrudingStart = False self.assertTrue(not self.Extruder.is_triggered(triggers)) # test OnExtrudingStart - False Filter triggers = ExtruderTriggers(False, None, None, None, None, None, None, None, None, None) # test True with False filter state.IsExtrudingStart = True self.assertTrue(not self.Extruder.is_triggered(triggers)) # test False with False filter state.IsExtrudingStart = False self.assertTrue(not self.Extruder.is_triggered(triggers))
def test_ExtruderStateCopy(self): # create a new state state = ExtruderState() # change all the default values state.E = 1 state.ExtrusionLength = 100 state.ExtrusionLengthTotal = 200 state.RetractionLength = 300 state.DetractionLength = 400 state.IsExtrudingStart = True state.IsExtruding = True state.IsPrimed = True state.IsRetractingStart = True state.IsRetracting = True state.IsPartiallyRetracted = True state.IsRetracted = True state.IsDetractingStart = True state.IsDetracting = True state.IsDetracted = True state.HasChanged = True # copy to a new state new_state = ExtruderState(state) # verify the state was copied correctly self.assertEquals(new_state.E, 1) self.assertEquals(new_state.ExtrusionLength, 100) self.assertEquals(new_state.ExtrusionLengthTotal, 200) self.assertEquals(new_state.RetractionLength, 300) self.assertEquals(new_state.DetractionLength, 400) self.assertTrue(new_state.IsExtrudingStart) self.assertTrue(new_state.IsExtruding) self.assertTrue(new_state.IsPrimed) self.assertTrue(new_state.IsRetractingStart) self.assertTrue(new_state.IsRetracting) self.assertTrue(new_state.IsPartiallyRetracted) self.assertTrue(new_state.IsRetracted) self.assertTrue(new_state.IsDetractingStart) self.assertTrue(new_state.IsDetracting) self.assertTrue(new_state.IsDetracted) self.assertTrue(new_state.HasChanged)
def test_extruderTriggers_Mixed(self): # Test mixed nones, trues and falses self.Extruder.reset() state = ExtruderState() self.Extruder.add_state(state) triggers = ExtruderTriggers(None, True, False, None, True, False, None, True, False, None) # Forbidden Due to IsPrimed state.IsExtrudingStart = True state.IsExtruding = True state.IsPrimed = True state.IsRetractingStart = True state.IsRetracting = True state.IsPartiallyRetracted = False state.IsRetracted = True state.IsDetractingStart = True state.IsDetracting = False state.IsDetracted = True self.assertTrue(not self.Extruder.is_triggered(triggers)) # True - is extruding state.IsExtrudingStart = False state.IsExtruding = True state.IsPrimed = False state.IsRetractingStart = True state.IsRetracting = False state.IsPartiallyRetracted = False state.IsRetracted = True state.IsDetractingStart = False state.IsDetracting = False state.IsDetracted = True self.assertTrue(self.Extruder.is_triggered(triggers)) # Test all false states and all Nones state.IsExtrudingStart = True state.IsExtruding = True state.IsPrimed = True state.IsRetractingStart = True state.IsRetracting = True state.IsPartiallyRetracted = True state.IsRetracted = True state.IsDetractingStart = True state.IsDetracting = True state.IsDetracted = True triggers = ExtruderTriggers(None, None, None, None, None, None, None, None, None, None) self.assertTrue(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(False, True, True, True, True, True, True, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, False, True, True, True, True, True, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, False, True, True, True, True, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, False, True, True, True, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, True, False, True, True, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, True, True, False, True, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, True, True, True, False, True, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, True, True, True, True, False, True, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, True, True, True, True, True, False, True) self.assertFalse(self.Extruder.is_triggered(triggers)) triggers = ExtruderTriggers(True, True, True, True, True, True, True, True, True, False) self.assertFalse(self.Extruder.is_triggered(triggers))