def test_get_current_aligner_position(self): """ Test getCurrentPositionLabel function behaves as expected """ aligner = self.aligner # at start the aligner wouldn't be in one of the predefined positions pos_label = getCurrentAlignerPositionLabel(aligner.position.value, aligner) self.assertTrue(pos_label in (LOADING_PATH, UNKNOWN)) # Move to loading position self.test_move_aligner_to_target(LOADING) # Move to imaging position and cancel the movement before reaching there f = cryoSwitchAlignPosition(IMAGING) time.sleep(5) f.cancel() pos_label = getCurrentAlignerPositionLabel(aligner.position.value, aligner) self.assertEqual(pos_label, LOADING_PATH) # simulate moving to unknown position by moving in opposite to deactive-active line unknown_pos = copy.copy(self.align_active) unknown_pos['y'] += 0.005 unknown_pos['z'] += 0.005 self.aligner.moveAbs(unknown_pos).result() pos_label = getCurrentAlignerPositionLabel(aligner.position.value, aligner) self.assertEqual(pos_label, UNKNOWN) # moving to either imaging/alignment positions shouldn't be allowed with self.assertRaises(ValueError): f = cryoSwitchAlignPosition(IMAGING) f.result() with self.assertRaises(ValueError): f = cryoSwitchAlignPosition(ALIGNMENT) f.result() # Move to alignment position cryoSwitchAlignPosition(LOADING).result() self.test_move_aligner_to_target(ALIGNMENT) # from alignment to loading cryoSwitchAlignPosition(LOADING).result() # Move to imaging position self.test_move_aligner_to_target(IMAGING)
def test_move_aligner_to_target(self, target): f = cryoSwitchAlignPosition(target) f.result() pos_label = getCurrentAlignerPositionLabel(self.aligner.position.value, self.aligner) self.assertEqual(pos_label, target)