예제 #1
0
def test_constant_energy_no_change(transfocator):
    # tests constant_energy when there is no change to the req_energy pv
    initial_energy = 9536.5
    transfocator.req_energy.put(initial_energy)
    transfocator.beam_energy.put(initial_energy)

    def nothing(transfocator):
        pass

    wrapped_func = constant_energy(nothing)
    wrapped_func(transfocator, 'req_energy', 0.1)
    wrapped_func(transfocator, 'beam_energy', 0.1)
예제 #2
0
def test_constant_energy_with_change(transfocator):
    # tests constant_energy when there is a signficant change to the req_energy
    # or beam_energy pv
    initial_energy = 9536.5
    transfocator.req_energy.put(initial_energy)
    transfocator.beam_energy.put(initial_energy)
    new_energy = 9530.1

    def change_energy(transfocator, new_energy):
        transfocator.req_energy.put(new_energy)
        transfocator.beam_energy.put(new_energy)

    with pytest.raises(TransfocatorEnergyInterrupt):
        wrapped_func = constant_energy(change_energy)
        wrapped_func(transfocator, 'req_energy', 0.1, new_energy)
        wrapped_func(transfocator, 'beam_energy', 0.1, new_energy)
예제 #3
0
def test_constant_energy_bad_input(transfocator):
    def nothing(transfocator):
        pass
    with pytest.raises(AttributeError):
        wrapped_func = constant_energy(nothing)
        wrapped_func(transfocator, 'bad_input_string', 0.1)