Esempio n. 1
0
def test_write_read_spectrum_attribute(tango_test,
                                       writable_spectrum_attribute):
    "Check that writable spectrum attributes can be written and read"
    attr_name = writable_spectrum_attribute
    config = tango_test.get_attribute_config(attr_name, wait=True)
    use_all_elements = True
    if is_bool_type(config.data_type):
        write_values = [True, False]
    elif is_int_type(config.data_type):
        write_values = [76, 77]
    elif is_float_type(config.data_type):
        write_values = [-28.2, 44.3]
    elif is_str_type(config.data_type):
        # string spectrum attributes don't reduce their x dimension
        # when written to, so we only compare the values written
        use_all_elements = False
        write_values = ["hello", "hola"]
    else:
        pytest.xfail("Not currently testing this type")

    tango_test.write_attribute(attr_name, write_values, wait=True)
    read_attr = tango_test.read_attribute(attr_name, wait=True)
    if use_all_elements:
        read_values = read_attr.value
    else:
        read_values = read_attr.value[0:len(write_values)]
    assert_close(read_values, write_values)
Esempio n. 2
0
def test_write_scalar_attribute(tango_test, writable_scalar_attribute):
    "Check that writable scalar attributes can be written"
    attr_name = writable_scalar_attribute
    config = tango_test.get_attribute_config(writable_scalar_attribute)
    if is_bool_type(config.data_type):
        tango_test.write_attribute(attr_name, True, wait=True)
    elif is_int_type(config.data_type):
        tango_test.write_attribute(attr_name, 76, wait=True)
    elif is_float_type(config.data_type):
        tango_test.write_attribute(attr_name, -28.2, wait=True)
    elif is_str_type(config.data_type):
        tango_test.write_attribute(attr_name, "hello", wait=True)
    else:
        pytest.xfail("Not currently testing this type")