def test_different_calibration_unit(): calibration = LinearCalibration(q.count / q.deg, 0 * q.deg) motor = DummyMotor(calibration) motor.position = 0 * q.deg motor.move(1 * q.deg).wait() assert motor.position == 1 * q.deg
class TestDummyMotor(unittest.TestCase): def setUp(self): self.motor = DummyMotor() self.handler = logbook.TestHandler() self.handler.push_application() def tearDown(self): self.handler.pop_application() def test_set_position(self): position = 1 * q.mm self.motor.position = position self.assertEqual(position, self.motor.position) def test_move(self): position = 1 * q.mm delta = 0.5 * q.mm self.motor.position = position self.motor.move(delta).wait() self.assertEqual(position + delta, self.motor.position) def test_log_output(self): self.motor.position = 0 * q.mm info = "Motor: try position='0.0 mm'" self.assertTrue(self.handler.has_info(info)) self.motor.position = 2 * q.mm info = "Motor: try position='2.0 mm'" self.assertTrue(self.handler.has_info(info))
class TestDummyMotor(TestCase): def setUp(self): super(TestDummyMotor, self).setUp() self.motor = DummyMotor() def test_set_position(self): position = 1 * q.mm self.motor.position = position self.assertEqual(position, self.motor.position) def test_move(self): position = 1 * q.mm delta = 0.5 * q.mm self.motor.position = position self.motor.move(delta).wait() self.assertEqual(position + delta, self.motor.position)