def test_group_updated_in_ads_calls_any_change_handle(self): CreateSampleWorkspace(OutputWorkspace="ws1") CreateSampleWorkspace(OutputWorkspace="ws2") GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="NewGroup") CreateSampleWorkspace(OutputWorkspace="ws3") self.project.anyChangeHandle = mock.MagicMock() ADS.addToGroup("NewGroup", "ws3") self.assertEqual(1, self.project.anyChangeHandle.call_count)
def test_group_updated_in_ads_calls_any_change_handle(self): CreateSampleWorkspace(OutputWorkspace="ws1") CreateSampleWorkspace(OutputWorkspace="ws2") GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="NewGroup") CreateSampleWorkspace(OutputWorkspace="ws3") self.project.anyChangeHandle = mock.MagicMock() ADS.addToGroup("NewGroup", "ws3") self.assertEqual(1, self.project.anyChangeHandle.call_count)
def test_observeGroupUpdated_calls_groupUpdateHandle_when_set_on_ads_and_a_group_in_the_ads_is_updated(self): CreateSampleWorkspace(OutputWorkspace="ws1") CreateSampleWorkspace(OutputWorkspace="ws2") CreateSampleWorkspace(OutputWorkspace="ws3") GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="NewGroup") self.fake_class.observeGroupUpdate(True) self.fake_class.groupUpdateHandle = mock.MagicMock() ADS.addToGroup("NewGroup", "ws3") self.assertEqual(self.fake_class.groupUpdateHandle.call_count, 1)
def test_addToGroup_adds_workspace_to_group(self): from mantid.simpleapi import CreateSampleWorkspace, GroupWorkspaces CreateSampleWorkspace(OutputWorkspace="ws1") CreateSampleWorkspace(OutputWorkspace="ws2") GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="NewGroup") CreateSampleWorkspace(OutputWorkspace="ws3") AnalysisDataService.addToGroup("NewGroup", "ws3") group = mtd['NewGroup'] self.assertEqual(group.size(), 3) self.assertCountEqual(group.getNames(), ["ws1", "ws2", "ws3"])
def test_addToGroup_adds_workspace_to_group(self): from mantid.simpleapi import CreateSampleWorkspace, GroupWorkspaces CreateSampleWorkspace(OutputWorkspace="ws1") CreateSampleWorkspace(OutputWorkspace="ws2") GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="NewGroup") CreateSampleWorkspace(OutputWorkspace="ws3") AnalysisDataService.addToGroup("NewGroup", "ws3") group = mtd['NewGroup'] self.assertEquals(group.size(), 3) six.assertCountEqual(self, group.getNames(), ["ws1", "ws2", "ws3"])
def test_when_nested_workspaces_are_being_saved_from_the_ADS(self, logger): CreateSampleWorkspace(OutputWorkspace="ws1") CreateSampleWorkspace(OutputWorkspace="ws2") CreateSampleWorkspace(OutputWorkspace="ws3") CreateSampleWorkspace(OutputWorkspace="ws4") GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="group1") GroupWorkspaces(InputWorkspaces="ws4,ws3", OutputWorkspace="group2") ADS.addToGroup("group2", "group1") ws_saver = workspacesaver.WorkspaceSaver(self.working_directory) ws_saver.save_workspaces(["group2"]) self.assertListEqual(["group1", "group2", "ws1", "ws2", "ws3", "ws4"], ADS.getObjectNames()) logger.warning.assert_called_with(u'Couldn\'t save workspace in project: "group2" because SaveNexusProcessed: ' u'NeXus files do not support nested groups of groups')
def test_observeAll_calls_anyChangeHandle_when_set_on_ads_group_updated(self): self.fake_class.observeAll(True) CreateSampleWorkspace(OutputWorkspace="ws1") expected_count = 1 CreateSampleWorkspace(OutputWorkspace="ws2") expected_count += 1 CreateSampleWorkspace(OutputWorkspace="ws3") expected_count += 1 GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="NewGroup") # One for grouping the workspace expected_count += 1 # One for adding it to the ADS expected_count += 1 # Will update group ADS.addToGroup("NewGroup", "ws3") expected_count += 1 self.assertEqual(self.fake_class.anyChangeHandle.call_count, expected_count)