예제 #1
0
class TestGdaHardwareMonitor(unittest.TestCase):

    def setUp(self):
        dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f'])
        self.grp = ScannableGroup('grp', dummy)
        self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6),
                                                   self.grp)
        self.energyhw = MockMotor()
        self.hardware = ScannableHardwareAdapter(self.diffhw,
                                                       self.energyhw)

    def test__init__Andget_axes_names(self):
        self.assertEquals(self.hardware.get_axes_names(),
                          ('a', 'b', 'c', 'd', 'e', 'f'))

    def testGetPosition(self):
        self.diffhw.asynchronousMoveTo((1, 2, 3, 4, 5, 6))
        self.assertEqual(self.hardware.get_position(),
                         [1.0, 2.0, 3.0, 4.0, 5.0, 6.0])

    def testGetEnergy(self):
        self.energyhw.asynchronousMoveTo(1.0)
        self.assertEqual(self.hardware.get_energy(), 1.0)

    def testGetWavelength(self):
        self.energyhw.asynchronousMoveTo(1.0)
        self.assertEqual(self.hardware.get_wavelength(), 12.39842 / 1.0)
예제 #2
0
 def setup_method(self):
     dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f'])
     self.grp = ScannableGroup('grp', dummy)
     self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6),
                                                self.grp)
     self.energyhw = MockMotor()
     self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw)
예제 #3
0
 def setup_method(self):
     dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f'])
     self.grp = ScannableGroup('grp', dummy)
     self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6),
                                                self.grp)
     self.energyhw = MockMotor()
     self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw)
class TestGdaHardwareMonitor(object):
    def setup_method(self):
        dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f'])
        self.grp = ScannableGroup('grp', dummy)
        self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6),
                                                   self.grp)
        self.energyhw = MockMotor()
        self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw)

    def test__init__Andget_axes_names(self):
        assert self.hardware.get_axes_names() == ('a', 'b', 'c', 'd', 'e', 'f')

    def testGetPosition(self):
        self.diffhw.asynchronousMoveTo((1, 2, 3, 4, 5, 6))
        assert self.hardware.get_position() == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]

    def testGetEnergy(self):
        self.energyhw.asynchronousMoveTo(1.0)
        assert self.hardware.get_energy() == 1.0

    def testGetWavelength(self):
        self.energyhw.asynchronousMoveTo(1.0)
        assert self.hardware.get_wavelength() == 12.39842 / 1.0

    def testLowerLimitSetAndGet(self):
        self.hardware.set_lower_limit('a', -1)
        self.hardware.set_lower_limit('b', -2)
        self.hardware.set_lower_limit('c', -3)
        with pytest.raises(DiffcalcException):
            self.hardware.set_lower_limit('not an angle', 1)
        self.hardware.set_lower_limit('d', None)
        print "Should print WARNING:"
        self.hardware.set_lower_limit('d', None)
        assert self.hardware.get_lower_limit('a') == -1
        assert self.hardware.get_lower_limit('c') == -3

    def testUpperLimitSetAndGet(self):
        self.hardware.set_upper_limit('a', 1)
        self.hardware.set_upper_limit('b', 2)
        self.hardware.set_upper_limit('c', 3)
        with pytest.raises(DiffcalcException):
            self.hardware.set_upper_limit('not an angle', 1)
        self.hardware.set_upper_limit('d', None)
        print "Should print WARNING:"
        self.hardware.set_upper_limit('d', None)
        assert self.hardware.get_upper_limit('a') == 1
        assert self.hardware.get_upper_limit('c') == 3
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()
예제 #6
0
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)
예제 #7
0
class TestGdaHardwareMonitor(object):
    def setup_method(self):
        dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f'])
        self.grp = ScannableGroup('grp', dummy)
        self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6),
                                                   self.grp)
        self.energyhw = MockMotor()
        self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw)

    def test__init__Andget_axes_names(self):
        assert self.hardware.get_axes_names() == ('a', 'b', 'c', 'd', 'e', 'f')

    def testGetPosition(self):
        self.diffhw.asynchronousMoveTo((1, 2, 3, 4, 5, 6))
        assert self.hardware.get_position() == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]

    def testGetEnergy(self):
        self.energyhw.asynchronousMoveTo(1.0)
        assert self.hardware.get_energy() == 1.0

    def testGetWavelength(self):
        self.energyhw.asynchronousMoveTo(1.0)
        assert self.hardware.get_wavelength() == 12.39842 / 1.0
예제 #8
0
 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)
예제 #9
0
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__()
 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 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)
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__()
예제 #13
0
 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))