class Ui_ReactionEditDialog(object): def setupUi(self, ReactionEditDialog): ReactionEditDialog.setObjectName("ReactionEditDialog") ReactionEditDialog.resize(383, 200) self.verticalLayout = QtWidgets.QVBoxLayout(ReactionEditDialog) self.verticalLayout.setObjectName("verticalLayout") self.attributeWidget = ReactionAttributesDisplayWidget(ReactionEditDialog) self.attributeWidget.setObjectName("attributeWidget") self.verticalLayout.addWidget(self.attributeWidget) self.tabWidget = QtWidgets.QTabWidget(ReactionEditDialog) self.tabWidget.setTabShape(QtWidgets.QTabWidget.Rounded) self.tabWidget.setObjectName("tabWidget") self.metaboliteTab = StoichiometryDisplayWidget() self.metaboliteTab.setObjectName("metaboliteTab") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.metaboliteTab) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.tabWidget.addTab(self.metaboliteTab, "") self.geneTab = GenesDisplayWidget() self.geneTab.setObjectName("geneTab") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.geneTab) self.verticalLayout_3.setObjectName("verticalLayout_3") self.tabWidget.addTab(self.geneTab, "") self.annotationTab = AnnotationDisplayWidget() self.annotationTab.setObjectName("annotationTab") self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.annotationTab) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.tabWidget.addTab(self.annotationTab, "") self.evidenceTab = EvidenceDisplayWidget() self.evidenceTab.setObjectName("evidenceTab") self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.evidenceTab) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.tabWidget.addTab(self.evidenceTab, "") self.commentTab = CommentDisplayWidget() self.commentTab.setObjectName("commentTab") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.commentTab) self.verticalLayout_6.setObjectName("verticalLayout_6") self.tabWidget.addTab(self.commentTab, "") self.verticalLayout.addWidget(self.tabWidget) self.buttonBox = QtWidgets.QDialogButtonBox(ReactionEditDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Save) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(ReactionEditDialog) self.tabWidget.setCurrentIndex(0) self.buttonBox.accepted.connect(ReactionEditDialog.accept) self.buttonBox.rejected.connect(ReactionEditDialog.reject) QtCore.QMetaObject.connectSlotsByName(ReactionEditDialog) def retranslateUi(self, ReactionEditDialog): _translate = QtCore.QCoreApplication.translate ReactionEditDialog.setWindowTitle(_translate("ReactionEditDialog", "Edit reaction")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.metaboliteTab), _translate("ReactionEditDialog", "Metabolites")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.geneTab), _translate("ReactionEditDialog", "Genes")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.annotationTab), _translate("ReactionEditDialog", "Annotations")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.evidenceTab), _translate("ReactionEditDialog", "Evidence")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.commentTab), _translate("ReactionEditDialog", "Comment"))
def test_reaction_enormous_bounds(self): widget = ReactionAttributesDisplayWidget() model = Model() reaction = Reaction(id="test", lower_bound=-999999, upper_bound=999999) widget.set_item(reaction, model) assert widget.lowerBoundInput.value() == -999999 assert widget.upperBoundInput.value() == 999999 assert widget.lowerBoundInput.minimum() == -999999 assert widget.upperBoundInput.maximum() == 999999
def test_standard_reaction_bounds(self): """ Check that bounds are set to standard values when the upper and lower bound are smaller""" widget = ReactionAttributesDisplayWidget() model = Model() reaction = Reaction(lower_bound=-500, upper_bound=100) widget.set_item(reaction, model) assert widget.lowerBoundInput.value() == -500 assert widget.lowerBoundInput.maximum() == 100. assert widget.lowerBoundInput.minimum() == -1000. assert widget.upperBoundInput.value() == 100 assert widget.upperBoundInput.maximum() == 1000. assert widget.upperBoundInput.minimum() == -500.
def test_setting_objective_value(self): widget = ReactionAttributesDisplayWidget() model = Model() reaction = Reaction(id="test") model.add_reactions((reaction, )) widget.set_item(reaction, model) new_value = 1. assert reaction.objective_coefficient != new_value widget.objectiveCoefficientInput.clear() QtTest.QTest.keyClicks(widget.objectiveCoefficientInput, str(new_value)) assert widget.objectiveCoefficientInput.value() == new_value assert widget.content_changed is True assert widget.valid_inputs() is True
def test_setting_lower_bound(self): widget = ReactionAttributesDisplayWidget() model = Model() reaction = Reaction(id="test") widget.set_item(reaction, model) current_max = widget.lowerBoundInput.maximum() current_min = widget.lowerBoundInput.minimum() current_max_upper = widget.upperBoundInput.maximum() widget.lowerBoundInput.clear() QtTest.QTest.keyClicks(widget.lowerBoundInput, "-2000") assert widget.lowerBoundInput.value() == -200. assert widget.upperBoundInput.minimum() == -200. assert widget.lowerBoundInput.maximum() == current_max assert widget.lowerBoundInput.minimum() == current_min assert widget.upperBoundInput.maximum() == current_max_upper
def test_setting_upper_bound(self): widget = ReactionAttributesDisplayWidget() model = Model() reaction = Reaction(id="test") widget.set_item(reaction, model) # Clear input first as spinbox is already at max current_max = widget.upperBoundInput.maximum() current_min = widget.upperBoundInput.minimum() current_min_lower = widget.lowerBoundInput.minimum() widget.upperBoundInput.clear() QtTest.QTest.keyClicks(widget.upperBoundInput, "500") assert widget.upperBoundInput.value() == 500 assert widget.lowerBoundInput.maximum() == 500. assert widget.upperBoundInput.maximum() == current_max assert widget.upperBoundInput.minimum() == current_min assert widget.lowerBoundInput.minimum() == current_min_lower
def test_changed_triggered_by_objective_coefficient_change(self): widget = ReactionAttributesDisplayWidget() mock = Mock() widget.changed.connect(mock.test) assert mock.test.called is False QtTest.QTest.keyClicks(widget.objectiveCoefficientInput, "3") assert mock.test.called is True
def test_changed_triggered_by_upper_bound_change(self): widget = ReactionAttributesDisplayWidget() mock = Mock() widget.changed.connect(mock.test) assert mock.test.called is False QtTest.QTest.keyClicks(widget.upperBoundInput, "3") assert mock.test.called is True
def test_changed_triggered_by_subsystem_change(self): widget = ReactionAttributesDisplayWidget() mock = Mock() widget.changed.connect(mock.test) assert mock.test.called is False QtTest.QTest.keyClicks(widget.subsystemLineEdit, "A") assert mock.test.called is True
def test_saving_changes(self): widget = ReactionAttributesDisplayWidget() reaction = Reaction("r1") model = Model("id") model.add_reactions((reaction, )) widget.set_item(reaction, model) new_id = "New id" new_name = "New name" new_subsytem = "New Subsystem" new_upper_bound = 200.5 new_lower_bound = -300.5 new_obj_coefficient = 20.4 widget.idLineEdit.setText(new_id) widget.nameLineEdit.setText(new_name) widget.subsystemLineEdit.setText(new_subsytem) widget.upperBoundInput.setValue(new_upper_bound) widget.lowerBoundInput.setValue(new_lower_bound) widget.objectiveCoefficientInput.setValue(new_obj_coefficient) # Action widget.save_state() # Check that inputs are saved assert reaction.id == new_id assert reaction.name == new_name assert reaction.subsystem == new_subsytem assert reaction.lower_bound == new_lower_bound assert reaction.upper_bound == new_upper_bound assert reaction.objective_coefficient == new_obj_coefficient
def test_setting_reaction(self): widget = ReactionAttributesDisplayWidget() reaction = Reaction(id="id", name="name", subsystem="subsystem", lower_bound=-1000., upper_bound=1000.) model = Model() model.add_reactions((reaction, )) reaction.objective_coefficient = 1. assert widget.idLineEdit.text() == "" assert widget.nameLineEdit.text() == "" assert widget.subsystemLineEdit.text() == "" assert widget.lowerBoundInput.value() == 0. assert widget.upperBoundInput.value() == 0. assert widget.objectiveCoefficientInput.value() == 0. assert widget.content_changed is False assert widget.valid_inputs() is False widget.set_item(reaction, model) assert widget.idLineEdit.text() == reaction.id assert widget.nameLineEdit.text() == reaction.name assert widget.subsystemLineEdit.text() == reaction.subsystem assert widget.lowerBoundInput.value() == reaction.lower_bound assert widget.upperBoundInput.value() == reaction.upper_bound assert widget.objectiveCoefficientInput.value( ) == reaction.objective_coefficient assert widget.content_changed is False assert widget.valid_inputs() is True
def test_valid_input(self): reaction = Reaction(id="test") model = Model() widget = ReactionAttributesDisplayWidget() widget.set_item(reaction, model) assert widget.valid_inputs() is True widget.idLineEdit.clear() assert widget.valid_inputs() is False
def test_setting_subsystem(self): widget = ReactionAttributesDisplayWidget() model = Model() reaction = Reaction(id="id") widget.set_item(reaction, model) assert widget.content_changed is False assert widget.valid_inputs() is True QtTest.QTest.keyClicks(widget.subsystemLineEdit, "Test") assert widget.content_changed is True assert widget.valid_inputs() is True