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()
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)
class TestDiffractometerScannableGroup(object): def setup_method(self): self.a = MockMotor() self.b = MockMotor() self.c = MockMotor() self.d = MockMotor() self.e = MockMotor() self.f = MockMotor() self.grp = ScannableGroup( 'grp', [self.a, self.b, self.c, self.d, self.e, self.f]) self.grp.configure() self.sg = DiffractometerScannableGroup( 'sixc', MockDiffcalc(6), self.grp) def testInit(self): assert list(self.sg.getPosition()) == [0., 0., 0., 0., 0., 0.] def testAsynchronousMoveTo(self): self.sg.asynchronousMoveTo([1, 2.0, 3, 4, 5, 6]) assert list(self.sg.getPosition()) == [1., 2., 3., 4., 5., 6.] def testAsynchronousMoveToWithNones(self): self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) self.sg.asynchronousMoveTo([None, None, 3.2, None, 5.2, None]) assert list(self.sg.getPosition()) == [1., 2., 3.2, 4., 5.2, 6.] def testGetPosition(self): #implicitely tested above pass def testWhereMoveTo(self): # just check for exceptions print self.sg.simulateMoveTo((1.23, 2, 3, 4, 5, 6)) def testIsBusy(self): assert not self.sg.isBusy() self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4, 5, 6]) assert self.sg.isBusy() self.b.makeNotBusy() assert self.sg.isBusy() self.a.makeNotBusy() self.c.makeNotBusy() self.d.makeNotBusy() self.e.makeNotBusy() self.f.makeNotBusy() assert not self.sg.isBusy() def testRepr(self): print self.sg.__repr__()
class TestDiffractometerScannableGroup(object): def setup_method(self): self.a = MockMotor() self.b = MockMotor() self.c = MockMotor() self.d = MockMotor() self.e = MockMotor() self.f = MockMotor() self.grp = ScannableGroup( 'grp', [self.a, self.b, self.c, self.d, self.e, self.f]) self.grp.configure() self.sg = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp) def testInit(self): assert list(self.sg.getPosition()) == [0., 0., 0., 0., 0., 0.] def testAsynchronousMoveTo(self): self.sg.asynchronousMoveTo([1, 2.0, 3, 4, 5, 6]) assert list(self.sg.getPosition()) == [1., 2., 3., 4., 5., 6.] def testAsynchronousMoveToWithNones(self): self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) self.sg.asynchronousMoveTo([None, None, 3.2, None, 5.2, None]) assert list(self.sg.getPosition()) == [1., 2., 3.2, 4., 5.2, 6.] def testGetPosition(self): #implicitely tested above pass def testWhereMoveTo(self): # just check for exceptions print self.sg.simulateMoveTo((1.23, 2, 3, 4, 5, 6)) def testIsBusy(self): assert not self.sg.isBusy() self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4, 5, 6]) assert self.sg.isBusy() self.b.makeNotBusy() assert self.sg.isBusy() self.a.makeNotBusy() self.c.makeNotBusy() self.d.makeNotBusy() self.e.makeNotBusy() self.f.makeNotBusy() assert not self.sg.isBusy() def testRepr(self): print self.sg.__repr__()