Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    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