Esempio n. 1
0
    def test_update_workspace_updates_model(self):
        region_selector = RegionSelector(view=Mock())
        mock_ws = Mock()

        region_selector.update_workspace(mock_ws)

        self.assertEqual(mock_ws, region_selector.model.ws)
Esempio n. 2
0
    def test_update_workspace_updates_view(self):
        mock_view = Mock()
        region_selector = RegionSelector(view=mock_view)
        mock_ws = Mock()

        region_selector.update_workspace(mock_ws)

        mock_view.set_workspace.assert_called_once_with(mock_ws)
Esempio n. 3
0
    def test_update_workspace_with_invalid_workspaces_fails(self):
        invalid_types = [WS_TYPE.MDH, WS_TYPE.MDE, None]
        mock_ws = Mock()
        region_selector = RegionSelector(view=Mock())

        for ws_type in invalid_types:
            self.patched_deps[
                "WorkspaceInfo"].get_ws_type.return_value = ws_type
            with self.assertRaisesRegex(NotImplementedError,
                                        "Matrix Workspaces"):
                region_selector.update_workspace(mock_ws)
Esempio n. 4
0
    def test_clear_workspace_will_clear_all_the_selectors_and_model_workspace(
            self):
        region_selector = RegionSelector(view=Mock())
        mock_ws = Mock()

        region_selector.update_workspace(mock_ws)
        region_selector.add_rectangular_region("test", "black")
        region_selector.add_rectangular_region("test", "black")

        region_selector.clear_workspace()

        self.assertEqual(0, len(region_selector._selectors))
        self.assertEqual(None, region_selector.model.ws)