Пример #1
0
    def test_GIVEN_user_function_engineering_correction_which_throws_WHEN_set_value_on_axis_THEN_0_correction(self):
        def _test_correction(setpoint):
            raise TypeError()

        engineering_correction = UserFunctionCorrection(_test_correction)

        result = engineering_correction.to_axis(0)

        assert_that(result, is_(close_to(0, FLOAT_TOLERANCE)))
Пример #2
0
    def test_GIVEN_user_function_engineering_correction_which_adds_no_correction_WHEN_set_value_on_axis_THEN_value_is_same_as_set(self):
        def _test_correction(setpoint):
            return 0

        value = 1
        expected_correction = value

        engineering_correction = UserFunctionCorrection(_test_correction)

        result = engineering_correction.to_axis(value)

        assert_that(result, is_(close_to(expected_correction, FLOAT_TOLERANCE)))
Пример #3
0
    def test_GIVEN_user_function_engineering_correction_which_adds_a_correction_of_the_setpoint_on_WHEN_set_value_on_axis_THEN_value_is_double_what_was_set(self):
        def _test_correction(setpoint):
            """Correction is the same as the setpoint so it doubles the correction"""
            return setpoint

        value = 1
        expected_correction = value*2

        engineering_correction = UserFunctionCorrection(_test_correction)

        result = engineering_correction.to_axis(value)

        assert_that(result, is_(close_to(expected_correction, FLOAT_TOLERANCE)))
Пример #4
0
    def test_GIVEN_user_function_engineering_correction_which_adds_setpoint_and_beamline_param_WHEN_set_value_on_axis_THEN_value_is_twice_value_plus_beamline_parameter_value(self):
        def _test_correction(setpoint, beamline_parameter):
            return setpoint + beamline_parameter

        parameter_value = 2
        comp = Component("param_comp", setup=PositionAndAngle(0, 0, 90))
        beamline_parameter = AxisParameter("param", comp, ChangeAxis.POSITION)
        beamline_parameter.sp = parameter_value

        value = 1
        expected_correction = value * 2 + parameter_value

        engineering_correction = UserFunctionCorrection(_test_correction, beamline_parameter)

        result = engineering_correction.to_axis(value)

        assert_that(result, is_(close_to(expected_correction, FLOAT_TOLERANCE)))