Esempio n. 1
0
    def test_init_from_param(self, qtbot, default_value):
        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)
        bool_input = BooleanInput(bool_param)
        qtbot.addWidget(bool_input)

        # test
        assert bool_input.text() == bool_param.name
        assert bool_input.value() == default_value
Esempio n. 2
0
    def test_setValue_should_update_value(self, qtbot, default_value):

        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)
        bool_input = BooleanInput(bool_param)
        qtbot.addWidget(bool_input)

        bool_input.setValue(not default_value)
        assert bool_input.value() == (not default_value)
Esempio n. 3
0
    def test_setValue_should_update_value(self, qtbot, default_value):

        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)
        bool_input = BooleanInput(bool_param)
        qtbot.addWidget(bool_input)

        bool_input.setValue(not default_value)
        assert bool_input.value() == (not default_value)
Esempio n. 4
0
    def test_init_from_param(self, qtbot, default_value):
        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)
        bool_input = BooleanInput(bool_param)
        qtbot.addWidget(bool_input)

        # test
        assert bool_input.text() == bool_param.name
        assert bool_input.value() == default_value
Esempio n. 5
0
    def test_init_from_param(self, qtbot, default_value,
                             value_remains_default):
        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)

        if (value_remains_default):
            # Enable check that the value is initialized to default_value
            check_value = default_value
        else:
            # Set to a non default value
            bool_param.value = not default_value
            # Enable check that the value is changed after initialization to a non default value
            check_value = not default_value

        bool_input = BooleanInput(bool_param)
        qtbot.addWidget(bool_input)

        # test
        assert bool_input.text() == bool_param.name
        assert bool_input.value() == check_value
Esempio n. 6
0
    def test_leftclick_should_update_parameter(self, qtbot, default_value):
        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)

        with mock.patch('test_inputs.BooleanParameter.value',
                        new_callable=mock.PropertyMock,
                        return_value=default_value) as p:
            bool_input = BooleanInput(bool_param)
            qtbot.addWidget(bool_input)
            bool_input.show()

            # TODO: fix: fails to toggle on Windows
            #qtbot.mouseClick(bool_input, QtCore.Qt.LeftButton)
            bool_input.setValue(not default_value)

            assert bool_input.value() == (not default_value)
            bool_input.parameter  # lazy update
            p.assert_called_once_with(not default_value)
Esempio n. 7
0
    def test_leftclick_should_update_parameter(self, qtbot, default_value):
        # set up BooleanInput
        bool_param = BooleanParameter('potato', default=default_value)

        with mock.patch('test_inputs.BooleanParameter.value',
                new_callable=mock.PropertyMock,
                return_value=default_value) as p:
            bool_input = BooleanInput(bool_param)
            qtbot.addWidget(bool_input)
            bool_input.show()

            # TODO: fix: fails to toggle on Windows
            #qtbot.mouseClick(bool_input, QtCore.Qt.LeftButton)
            bool_input.setValue(not default_value)

            assert bool_input.value() == (not default_value)
            bool_input.parameter # lazy update
            p.assert_called_once_with(not default_value)
Esempio n. 8
0
    def _make_input(self, name, parameter):
        if parameter.ui_class is not None:
            element = parameter.ui_class(parameter)

        elif isinstance(parameter, FloatParameter):
            element = ScientificInput(parameter)

        elif isinstance(parameter, IntegerParameter):
            element = IntegerInput(parameter)

        elif isinstance(parameter, BooleanParameter):
            element = BooleanInput(parameter)

        elif isinstance(parameter, ListParameter):
            element = ListInput(parameter)

        elif isinstance(parameter, FileParameter):
            element = FileInput(parameter)

        elif isinstance(parameter, DirectoryParameter):
            element = DirectoryInput(parameter)

        elif isinstance(parameter, TextEditParameter):
            element = FloatTextEditInput(parameter)

        elif isinstance(parameter, Parameter):
            element = StringInput(parameter)

        else:
            raise ValueError("unrecognized parameter type: {}".format(
                type(parameter)))

        setattr(self, name, element)

        if name in self._procedure.TOOLTIPS.keys():
            element.setToolTip(self._procedure.TOOLTIPS[name])