Exemplo n.º 1
0
def __update_existing_dataset_field(field: Dataset, new_ui_field: FieldWidget):
    new_ui_field.name = field.name
    new_ui_field.dtype = ValueTypes.STRING if not field.type else field.type
    new_ui_field.value = field.values  # type: ignore
    new_ui_field.attrs = field
    units = field.attributes.get_attribute_value(CommonAttrs.UNITS)
    new_ui_field.units = units
Exemplo n.º 2
0
def test_ui_field_GIVEN_field_has_units_filled_in_ui_WHEN_getting_field_group_THEN_units_are_stored_in_attrs(
    qtbot, ):
    listwidget = QListWidget()
    field = FieldWidget(None, POSSIBLE_FIELDS, listwidget)
    field_name = "test"
    field.name = field_name
    field.value_line_edit.setText("1")
    qtbot.addWidget(field)
    units = "m"
    field.units = units
    group = field.value

    assert group.attributes.contains_attribute("units")
    assert group.attributes.get_attribute_value("units") == units
Exemplo n.º 3
0
def test_ui_field_GIVEN_field_has_units_filled_in_ui_WHEN_getting_field_group_THEN_units_are_stored_in_attrs(
    qtbot, ):
    nexus_wrapper = NexusWrapper("test_ui_fields_units")
    instrument = Instrument(nexus_wrapper, NX_CLASS_DEFINITIONS)

    listwidget = QListWidget()
    field = FieldWidget(["test"], listwidget, instrument=instrument)
    field_name = "test"
    field.name = field_name
    field.value_line_edit.setText("1")
    qtbot.addWidget(field)
    units = "m"
    field.units = units
    group = field.value

    assert "units" in group.attrs
    assert group.attrs["units"] == units