def field_type_changed(self): self.edit_dialog = QDialog(parent=self) self.edit_dialog.setModal(True) self._set_up_value_validator(False) self.enable_3d_value_spinbox.emit(not self.field_type_is_scalar()) if self.field_type == FieldType.scalar_dataset: self.set_visibility(True, False, False, True) elif self.field_type == FieldType.array_dataset: self.set_visibility(False, False, True, True) self.table_view = ArrayDatasetTableWidget() elif self.field_type == FieldType.kafka_stream: self.set_visibility(False, False, True, False, show_name_line_edit=True) self.streams_widget = StreamFieldsWidget( self.edit_dialog, show_only_f142_stream=self._show_only_f142_stream) elif self.field_type == FieldType.link: self.set_visibility( True, False, False, False, show_unit_line_edit=False, show_attrs_edit=False, ) self._set_up_value_validator(False)
def test_ui_stream_field_GIVEN_f142_is_selected_WHEN_combo_is_changed_THEN_value_units_edit_is_shown( qtbot, ): listwidget = QListWidget() field = FieldWidget(["test"], listwidget) field_name = "test" field.name = field_name stream_fields_widget = StreamFieldsWidget(field) qtbot.addWidget(stream_fields_widget) stream_fields_widget.schema_combo.currentTextChanged.emit("f142") assert stream_fields_widget.value_units_edit.isEnabled() assert stream_fields_widget.value_units_label.isEnabled()
def stream_fields_widget(qtbot, instrument, template): class DummyField: @property def name(self): return "test" add_component_dialog = AddComponentDialog(instrument, ComponentTreeModel(instrument), nx_classes=NX_CLASS_DEFINITIONS) add_component_dialog.setupUi(template) field = add_component_dialog.create_new_ui_field(DummyField()) widget = StreamFieldsWidget(field.attrs_dialog) qtbot.addWidget(widget) return widget
def test_ui_stream_field_GIVEN_f142_is_selected_WHEN_advanced_options_are_clicked_THEN_f142_group_box_is_shown( qtbot, ): listwidget = QListWidget() field = FieldWidget(["test"], listwidget) field_name = "test" field.name = field_name stream_fields_widget = StreamFieldsWidget(field) stream_fields_widget.schema_combo.setCurrentText("f142") qtbot.addWidget(stream_fields_widget) stream_fields_widget.f142_advanced_group_box.setVisible = Mock() stream_fields_widget._show_advanced_options(True) stream_fields_widget.f142_advanced_group_box.setVisible.assert_called_once_with( True)
def field_type_changed(self): self.edit_dialog = QDialog(parent=self) self._set_up_value_validator(False) if self.field_type == FieldType.scalar_dataset: self.set_visibility(True, False, False, True) elif self.field_type == FieldType.array_dataset: self.set_visibility(False, False, True, True) self.table_view = ArrayDatasetTableWidget() elif self.field_type == FieldType.kafka_stream: self.set_visibility(False, False, True, False, show_name_line_edit=True) self.streams_widget = StreamFieldsWidget(self.edit_dialog) elif self.field_type == FieldType.link: self.set_visibility(True, False, False, False) self._set_up_value_validator(True) elif self.field_type == FieldType.nx_class: self.set_visibility(False, True, False, False)
def stream_fields_widget(qtbot, model, template): class DummyField: @property def name(self): return "test" entry = Entry() group = Group(name="some_name", parent_node=entry) entry.children.append(group) add_component_dialog = AddComponentDialog( None, model=model, component_model=ComponentTreeModel(model), nx_classes=NX_CLASS_DEFINITIONS, group_to_edit=group, scene_widget=None, initial_edit=False, ) field = add_component_dialog.create_new_ui_field(DummyField()) widget = StreamFieldsWidget(field.attrs_dialog) qtbot.addWidget(widget) return widget