class TestDiffractometerScannableGroup(unittest.TestCase): def setUp(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): self.assertEqual(list(self.sg.getPosition()), [0., 0., 0., 0., 0., 0.]) def testAsynchronousMoveTo(self): self.sg.asynchronousMoveTo([1, 2.0, 3, 4, 5, 6]) self.assertEqual(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]) self.assertEqual(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): self.assertEqual(self.sg.isBusy(), False) self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4, 5, 6]) self.assertEqual(self.sg.isBusy(), True) self.b.makeNotBusy() self.assertEqual(self.sg.isBusy(), True) self.a.makeNotBusy() self.c.makeNotBusy() self.d.makeNotBusy() self.e.makeNotBusy() self.f.makeNotBusy() self.assertEqual(self.sg.isBusy(), False) 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__()