class TestScannableGroup(unittest.TestCase):

    def setUp(self):
        self.a = MockMotor('a')
        self.b = MockMotor('bbb')
        self.c = MockMotor('c')
        self.sg = ScannableGroup('abc', (self.a, self.b, self.c))

    def testInit(self):
        self.assertEqual(list(self.sg.getInputNames()), ['a', 'bbb', 'c'])
        self.assertEqual(self.sg.getPosition(), [0.0, 0.0, 0.0])

    def testAsynchronousMoveTo(self):
        self.sg.asynchronousMoveTo([1, 2.0, 3])
        self.assertEqual(self.sg.getPosition(), [1.0, 2.0, 3.0])

    def testAsynchronousMoveToWithNones(self):
        self.sg.asynchronousMoveTo([1.0, 2.0, 3.0])
        self.sg.asynchronousMoveTo([None, None, 3.2])
        self.assertEqual(self.sg.getPosition(), [1.0, 2.0, 3.2])

    def testGetPosition(self):
        # implicitely tested above
        pass

    def testIsBusy(self):
        self.assertEqual(self.sg.isBusy(), False)
        self.sg.asynchronousMoveTo([1.0, 2.0, 3.0])
        self.assertEqual(self.sg.isBusy(), True)
        self.b.makeNotBusy()
        self.assertEqual(self.sg.isBusy(), True)
        self.a.makeNotBusy()
        self.c.makeNotBusy()
        self.assertEqual(self.sg.isBusy(), False)
Exemple #2
0
class TestScannableGroup(object):
    def setup_method(self):
        self.a = MockMotor('a')
        self.b = MockMotor('bbb')
        self.c = MockMotor('c')
        self.sg = ScannableGroup('abc', (self.a, self.b, self.c))

    def testInit(self):
        assert list(self.sg.getInputNames()) == ['a', 'bbb', 'c']
        assert self.sg.getPosition() == [0.0, 0.0, 0.0]

    def testAsynchronousMoveTo(self):
        self.sg.asynchronousMoveTo([1, 2.0, 3])
        assert self.sg.getPosition() == [1.0, 2.0, 3.0]

    def testAsynchronousMoveToWithNones(self):
        self.sg.asynchronousMoveTo([1.0, 2.0, 3.0])
        self.sg.asynchronousMoveTo([None, None, 3.2])
        assert self.sg.getPosition() == [1.0, 2.0, 3.2]

    def testGetPosition(self):
        # implicitely tested above
        pass

    def testIsBusy(self):
        assert not self.sg.isBusy()
        self.sg.asynchronousMoveTo([1.0, 2.0, 3.0])
        assert self.sg.isBusy()
        self.b.makeNotBusy()
        assert self.sg.isBusy()
        self.a.makeNotBusy()
        self.c.makeNotBusy()
        assert not self.sg.isBusy()