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)
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
Example #3
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