Ejemplo n.º 1
0
    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_upper_bound_changed = mock.Mock()
        self.view.sig_upper_bound_changed.emit = mock.Mock()
        self.view.sig_upper_bound_changed.connect = mock.Mock()
        self.view.sig_upper_bound_changed.disconnect = mock.Mock()

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

        self.slot = mock.Mock()
Ejemplo n.º 2
0
    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_upper_bound_changed = mock.Mock()
        self.view.sig_upper_bound_changed.emit = mock.Mock()
        self.view.sig_upper_bound_changed.connect = mock.Mock()
        self.view.sig_upper_bound_changed.disconnect = mock.Mock()

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

        self.slot = mock.Mock()
Ejemplo n.º 3
0
    def __init__(self):
        super(PlotView, self).__init__()
        self.plots = OrderedDict({})
        self.errors_list = set()
        self.plot_storage = {}  # stores lines and info to create lines
        self.current_grid = None
        self.gridspecs = {
            1: gridspec.GridSpec(1, 1),
            2: gridspec.GridSpec(1, 2),
            3: gridspec.GridSpec(3, 1),
            4: gridspec.GridSpec(2, 2)
        }
        self.figure = Figure()
        self.figure.set_facecolor("none")
        self.canvas = FigureCanvas(self.figure)

        self.plot_selector = QtWidgets.QComboBox()
        self._update_plot_selector()
        self.plot_selector.currentIndexChanged[str].connect(self._set_bounds)

        button_layout = QtWidgets.QHBoxLayout()
        self.x_axis_changer = AxisChangerPresenter(AxisChangerView("X"))
        self.x_axis_changer.on_upper_bound_changed(self._update_x_axis_upper)
        self.x_axis_changer.on_lower_bound_changed(self._update_x_axis_lower)

        self.y_axis_changer = AxisChangerPresenter(AxisChangerView("Y"))
        self.y_axis_changer.on_upper_bound_changed(self._update_y_axis_upper)
        self.y_axis_changer.on_lower_bound_changed(self._update_y_axis_lower)

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

        button_layout.addWidget(self.plot_selector)
        button_layout.addWidget(self.x_axis_changer.view)
        button_layout.addWidget(self.y_axis_changer.view)
        button_layout.addWidget(self.errors)

        grid = QtWidgets.QGridLayout()

        self.toolbar = myToolbar(self.canvas, self)
        self.toolbar.update()

        grid.addWidget(self.toolbar, 0, 0)
        grid.addWidget(self.canvas, 1, 0)
        grid.addLayout(button_layout, 2, 0)
        self.setLayout(grid)
Ejemplo n.º 4
0
class AxisChangerViewTest(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_upper_bound_changed = mock.Mock()
        self.view.sig_upper_bound_changed.emit = mock.Mock()
        self.view.sig_upper_bound_changed.connect = mock.Mock()
        self.view.sig_upper_bound_changed.disconnect = mock.Mock()

        self.view.sig_lower_bound_changed = mock.Mock()
        self.view.sig_lower_bound_changed.emit = mock.Mock()
        self.view.sig_lower_bound_changed.connect = mock.Mock()
        self.view.sig_lower_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__lower_bound_changed(self):
        self.view._lower_bound_changed()
        self.view.sig_lower_bound_changed.emit.assert_called_with(
            self.view.get_bounds()[0])

    def test__upper_bound_changed(self):
        self.view._upper_bound_changed()
        self.view.sig_upper_bound_changed.emit.assert_called_with(
            self.view.get_bounds()[1])

    def test_on_lower_bound_changed(self):
        self.view.on_lower_bound_changed(self.slot)
        self.view.sig_lower_bound_changed.connect.assert_called_with(self.slot)

    def test_on_upper_bound_changed(self):
        self.view.on_upper_bound_changed(self.slot)
        self.view.sig_upper_bound_changed.connect.assert_called_with(self.slot)

    def test_unreg_on_lower_bound_changed(self):
        self.view.unreg_on_lower_bound_changed(self.slot)
        self.view.sig_lower_bound_changed.disconnect.assert_called_with(
            self.slot)

    def test_unreg_on_upper_bound_changed(self):
        self.view.unreg_on_upper_bound_changed(self.slot)
        self.view.sig_upper_bound_changed.disconnect.assert_called_with(
            self.slot)
Ejemplo n.º 5
0
class AxisChangerViewTest(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_upper_bound_changed = mock.Mock()
        self.view.sig_upper_bound_changed.emit = mock.Mock()
        self.view.sig_upper_bound_changed.connect = mock.Mock()
        self.view.sig_upper_bound_changed.disconnect = mock.Mock()

        self.view.sig_lower_bound_changed = mock.Mock()
        self.view.sig_lower_bound_changed.emit = mock.Mock()
        self.view.sig_lower_bound_changed.connect = mock.Mock()
        self.view.sig_lower_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__lower_bound_changed(self):
        self.view._lower_bound_changed()
        self.view.sig_lower_bound_changed.emit.assert_called_with(
            self.view.get_bounds()[0])

    def test__upper_bound_changed(self):
        self.view._upper_bound_changed()
        self.view.sig_upper_bound_changed.emit.assert_called_with(
            self.view.get_bounds()[1])

    def test_on_lower_bound_changed(self):
        self.view.on_lower_bound_changed(self.slot)
        self.view.sig_lower_bound_changed.connect.assert_called_with(self.slot)

    def test_on_upper_bound_changed(self):
        self.view.on_upper_bound_changed(self.slot)
        self.view.sig_upper_bound_changed.connect.assert_called_with(self.slot)

    def test_unreg_on_lower_bound_changed(self):
        self.view.unreg_on_lower_bound_changed(self.slot)
        self.view.sig_lower_bound_changed.disconnect.assert_called_with(
            self.slot)

    def test_unreg_on_upper_bound_changed(self):
        self.view.unreg_on_upper_bound_changed(self.slot)
        self.view.sig_upper_bound_changed.disconnect.assert_called_with(
            self.slot)