Пример #1
0
    def test_remove_removes_named_workspace(self, mock_create_model):
        names = ["peaks1", 'peaks2', 'peaks3']
        presenter = PeaksViewerCollectionPresenter(MagicMock())
        for name in names:
            presenter.append_peaksworkspace(name)

        presenter.remove_peaksworkspace(names[1])

        self.assertEqual([names[0], names[2]], presenter.workspace_names())
Пример #2
0
    def test_hides_view_when_last_named_workspace_removed(
            self, mock_create_model):
        names = ["peaks1"]
        presenter = PeaksViewerCollectionPresenter(MagicMock())
        presenter.append_peaksworkspace(names[0])

        presenter.remove_peaksworkspace(names[0])

        presenter._actions_view.set_peaksworkspace.assert_called_with([])
        presenter._view.hide.assert_called()
Пример #3
0
    def test_ensure_delete_handle_removes_workspace(self, _):
        presenter = PeaksViewerCollectionPresenter(MagicMock())
        presenter.remove_peaksworkspace = MagicMock()
        presenter.workspace_names = MagicMock(return_value=["ws"])

        presenter.delete_handle("ws")

        presenter.remove_peaksworkspace.assert_called_once_with("ws")
Пример #4
0
    def test_ensure_clear_handle_removes_all_workspaces(self, _):
        presenter = PeaksViewerCollectionPresenter(MagicMock())
        presenter.remove_peaksworkspace = MagicMock()
        presenter.workspace_names = MagicMock(return_value=["ws", "ws1", "ws2"])

        presenter.clear_handle()

        presenter.remove_peaksworkspace.assert_any_call("ws")
        presenter.remove_peaksworkspace.assert_any_call("ws1")
        presenter.remove_peaksworkspace.assert_any_call("ws2")
        self.assertEqual(3, presenter.remove_peaksworkspace.call_count)
Пример #5
0
    def test_ensure_rename_handle_removes_and_re_adds_the_new_workspace_name(self, _):
        presenter = PeaksViewerCollectionPresenter(MagicMock())
        presenter.workspace_names = MagicMock(return_value=["ws"])

        def remove_peaks(ws_name):
            presenter.workspace_names().remove(ws_name)
            return 7
        presenter.remove_peaksworkspace = MagicMock(side_effect=remove_peaks)
        presenter.overlay_peaksworkspaces = MagicMock()

        presenter.rename_handle("ws", "ws1")

        presenter.remove_peaksworkspace.assert_called_once_with("ws")
        presenter.overlay_peaksworkspaces.assert_called_once_with(["ws1"], index=7)