def __init__(self, subcontext, parent=None):
        super(QuickEditView, self).__init__(parent)

        button_layout = QtWidgets.QHBoxLayout()
        self.plot_selector = QtWidgets.QComboBox()
        self.plot_selector.setEditable(True)
        self.plot_selector.completer().setCompletionMode(
            QtWidgets.QCompleter.PopupCompletion)
        if qtpy.PYQT5:
            self.plot_selector.completer().setFilterMode(
                QtCore.Qt.MatchContains)

        self.plot_selector.addItem("All")
        self.x_axis_changer = AxisChangerPresenter(AxisChangerView("X"))

        self.autoscale = QtWidgets.QPushButton("Autoscale y")
        self.autoscale.setStyleSheet("background-color:lightgrey")

        self.y_axis_changer = AxisChangerPresenter(AxisChangerView("Y"))

        self.errors = QtWidgets.QCheckBox("Errors")
        self.errors.stateChanged.connect(self._emit_errors)

        button_layout.addWidget(self.plot_selector)
        button_layout.addWidget(self.x_axis_changer.view)
        button_layout.addWidget(self.autoscale)
        button_layout.addWidget(self.y_axis_changer.view)
        button_layout.addWidget(self.errors)
        self.setLayout(button_layout)
    def setUp(self):
        label = "test"
        self.view = AxisChangerView(label)
        self.test_bounds = ["10", "20"]

        self.view.lower_bound.text = mock.Mock(
            return_value=self.test_bounds[0])
        self.view.upper_bound.text = mock.Mock(
            return_value=self.test_bounds[1])

        self.view.lower_bound.setText = mock.Mock()
        self.view.upper_bound.setText = mock.Mock()

        self.view.lower_bound.clear = mock.Mock()
        self.view.upper_bound.clear = mock.Mock()

        self.view.sig_bound_changed = mock.Mock()
        self.view.sig_bound_changed.emit = mock.Mock()
        self.view.sig_bound_changed.connect = mock.Mock()
        self.view.sig_bound_changed.disconnect = mock.Mock()

        self.slot = mock.Mock()
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        label = "test"
        self.view = AxisChangerView(label)
        self.test_bounds = ["10", "20"]

        self.view.lower_bound.text = mock.Mock(
            return_value=self.test_bounds[0])
        self.view.upper_bound.text = mock.Mock(
            return_value=self.test_bounds[1])

        self.view.lower_bound.setText = mock.Mock()
        self.view.upper_bound.setText = mock.Mock()

        self.view.lower_bound.clear = mock.Mock()
        self.view.upper_bound.clear = mock.Mock()

        self.view.sig_bound_changed = mock.Mock()
        self.view.sig_bound_changed.emit = mock.Mock()
        self.view.sig_bound_changed.connect = mock.Mock()
        self.view.sig_bound_changed.disconnect = mock.Mock()

        self.slot = mock.Mock()
Exemple #4
0
class AxisChangerTwoViewTest(unittest.TestCase):
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        label = "test"
        self.view = AxisChangerView(label)
        self.test_bounds = ["10", "20"]

        self.view.lower_bound.text = mock.Mock(
            return_value=self.test_bounds[0])
        self.view.upper_bound.text = mock.Mock(
            return_value=self.test_bounds[1])

        self.view.lower_bound.setText = mock.Mock()
        self.view.upper_bound.setText = mock.Mock()

        self.view.lower_bound.clear = mock.Mock()
        self.view.upper_bound.clear = mock.Mock()

        self.view.sig_bound_changed = mock.Mock()
        self.view.sig_bound_changed.emit = mock.Mock()
        self.view.sig_bound_changed.connect = mock.Mock()
        self.view.sig_bound_changed.disconnect = mock.Mock()

        self.slot = mock.Mock()

    def test_get_bounds(self):
        self.assertEqual(self.view.get_bounds(),
                         [int(bound) for bound in self.test_bounds])

    def test_set_bounds(self):
        self.view.set_bounds(self.test_bounds)
        self.view.lower_bound.setText.assert_called_with(self.test_bounds[0])
        self.view.upper_bound.setText.assert_called_with(self.test_bounds[1])

    def test_clear_bounds(self):
        self.view.clear_bounds()
        self.assertEquals(self.view.lower_bound.clear.call_count, 1)
        self.assertEquals(self.view.upper_bound.clear.call_count, 1)

    def test_bound_changed(self):
        self.view._bound_changed()
        self.view.sig_bound_changed.emit.assert_called_with(
            list(self.view.get_bounds()))

    def test_on_bound_changed(self):
        self.view.on_bound_changed(self.slot)
        self.view.sig_bound_changed.connect.assert_called_with(self.slot)

    def test_unreg_on_bound_changed(self):
        self.view.unreg_bound_changed(self.slot)
        self.view.sig_bound_changed.disconnect.assert_called_with(self.slot)
class AxisChangerTwoViewTest(unittest.TestCase):
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        label = "test"
        self.view = AxisChangerView(label)
        self.test_bounds = ["10", "20"]

        self.view.lower_bound.text = mock.Mock(
            return_value=self.test_bounds[0])
        self.view.upper_bound.text = mock.Mock(
            return_value=self.test_bounds[1])

        self.view.lower_bound.setText = mock.Mock()
        self.view.upper_bound.setText = mock.Mock()

        self.view.lower_bound.clear = mock.Mock()
        self.view.upper_bound.clear = mock.Mock()

        self.view.sig_bound_changed = mock.Mock()
        self.view.sig_bound_changed.emit = mock.Mock()
        self.view.sig_bound_changed.connect = mock.Mock()
        self.view.sig_bound_changed.disconnect = mock.Mock()

        self.slot = mock.Mock()

    def test_get_bounds(self):
        self.assertEqual(
            self.view.get_bounds(), [
                int(bound) for bound in self.test_bounds])

    def test_set_bounds(self):
        self.view.set_bounds(self.test_bounds)
        self.view.lower_bound.setText.assert_called_with(self.test_bounds[0])
        self.view.upper_bound.setText.assert_called_with(self.test_bounds[1])

    def test_clear_bounds(self):
        self.view.clear_bounds()
        self.assertEquals(self.view.lower_bound.clear.call_count, 1)
        self.assertEquals(self.view.upper_bound.clear.call_count, 1)

    def test_bound_changed(self):
        self.view._bound_changed()
        self.view.sig_bound_changed.emit.assert_called_with(
            list(self.view.get_bounds()))

    def test_on_bound_changed(self):
        self.view.on_bound_changed(self.slot)
        self.view.sig_bound_changed.connect.assert_called_with(self.slot)

    def test_unreg_on_bound_changed(self):
        self.view.unreg_bound_changed(self.slot)
        self.view.sig_bound_changed.disconnect.assert_called_with(
            self.slot)