Пример #1
0
    def test_setting_item(self):
        gene = Gene("test_id", "name", "genome")
        model = Model()

        widget = GeneAttributesDisplayWidget()

        # Test prestate
        assert widget.iDLineEdit.text() == ""
        assert widget.nameLineEdit.text() == ""
        assert widget.genomeLineEdit.text() == ""

        widget.set_item(gene, model)

        assert widget.iDLineEdit.text() == gene.id
        assert widget.nameLineEdit.text() == gene.name
        assert widget.genomeLineEdit.text() == gene.genome

        assert widget.valid_inputs() is True
        assert widget.content_changed is False

        widget.set_item(None, model)

        assert widget.iDLineEdit.text() == ""
        assert widget.nameLineEdit.text() == ""
        assert widget.genomeLineEdit.text() == ""

        assert widget.valid_inputs() is False
        assert widget.content_changed is False
Пример #2
0
class Ui_GeneEditDialog(object):
    def setupUi(self, GeneEditDialog):
        GeneEditDialog.setObjectName("GeneEditDialog")
        GeneEditDialog.resize(260, 182)
        self.verticalLayout = QtWidgets.QVBoxLayout(GeneEditDialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.attributeWidget = GeneAttributesDisplayWidget(GeneEditDialog)
        self.attributeWidget.setObjectName("attributeWidget")
        self.verticalLayout.addWidget(self.attributeWidget)
        self.tabWidget = QtWidgets.QTabWidget(GeneEditDialog)
        self.tabWidget.setObjectName("tabWidget")
        self.reactionTab = ReactionsDisplayWidget()
        self.reactionTab.setObjectName("reactionTab")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.reactionTab)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.tabWidget.addTab(self.reactionTab, "")
        self.tab_annotations = AnnotationDisplayWidget()
        self.tab_annotations.setObjectName("tab_annotations")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.tab_annotations)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.tabWidget.addTab(self.tab_annotations, "")
        self.evidenceTab = EvidenceDisplayWidget()
        self.evidenceTab.setObjectName("evidenceTab")
        self.tabWidget.addTab(self.evidenceTab, "")
        self.verticalLayout.addWidget(self.tabWidget)
        self.buttonBox = QtWidgets.QDialogButtonBox(GeneEditDialog)
        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(GeneEditDialog)
        self.tabWidget.setCurrentIndex(0)
        self.buttonBox.accepted.connect(GeneEditDialog.accept)
        self.buttonBox.rejected.connect(GeneEditDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(GeneEditDialog)

    def retranslateUi(self, GeneEditDialog):
        _translate = QtCore.QCoreApplication.translate
        GeneEditDialog.setWindowTitle(_translate("GeneEditDialog",
                                                 "Edit Gene"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.reactionTab),
                                  _translate("GeneEditDialog", "Reactions"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_annotations),
                                  _translate("GeneEditDialog", "Annotation"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.evidenceTab),
                                  _translate("GeneEditDialog", "Evidence"))
Пример #3
0
    def test_changed_triggered_by_genome_change(self):
        widget = GeneAttributesDisplayWidget()
        mock = Mock()
        widget.changed.connect(mock.test)

        assert mock.test.called is False
        QtTest.QTest.keyClicks(widget.genomeLineEdit, "A")
        assert mock.test.called is True
Пример #4
0
    def test_valid_input(self):
        gene = Gene(id="test")
        model = Model()

        widget = GeneAttributesDisplayWidget()

        widget.set_item(gene, model)
        assert widget.valid_inputs() is True
        widget.iDLineEdit.clear()
        assert widget.valid_inputs() is False
Пример #5
0
    def test_save_state(self):

        gene = Gene()
        model = Model()

        widget = GeneAttributesDisplayWidget()

        widget.set_item(gene, model)

        new_id = "New id"
        new_name = "New name"
        new_genome = "New genome"

        widget.iDLineEdit.setText(new_id)
        widget.nameLineEdit.setText(new_name)
        widget.genomeLineEdit.setText(new_genome)

        widget.save_state()

        assert gene.id == new_id
        assert gene.name == new_name
        assert gene.genome == new_genome