Skip to content
Snippets Groups Projects
Commit 162a64a1 authored by Matthew Andrew's avatar Matthew Andrew
Browse files

unit test to check groups named correctly Re #18933

parent dccbc8d8
No related branches found
No related tags found
No related merge requests found
......@@ -1633,28 +1633,48 @@ class TestRenamingOfBatchModeWorkspaces(unittest.TestCase):
def test_that_SANS2D_workspace_is_renamed_correctly(self):
workspace = self._create_sample_workspace()
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.LAB, "test", workspace)
workspace_name = workspace.getName()
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.LAB, "test", workspace_name)
self.assertTrue(AnalysisDataService.doesExist("test_rear"))
self.assertTrue(out_name == "test_rear")
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.HAB, "test", workspace)
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.HAB, "test", out_name)
self.assertTrue(AnalysisDataService.doesExist("test_front"))
self.assertTrue(out_name == "test_front")
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.Merged, "test", workspace)
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.Merged, "test", out_name)
self.assertTrue(AnalysisDataService.doesExist("test_merged"))
self.assertTrue(out_name == "test_merged")
if AnalysisDataService.doesExist("test_merged"):
AnalysisDataService.remove("test_merged")
def test_for_a_group_workspace_renames_entire_group(self):
workspace_t0_T1 = CreateSampleWorkspace(Function='Flat background', NumBanks=1, BankPixelWidth=1, NumEvents=1,
XMin=1, XMax=14, BinWidth=2)
workspace_t1_T2 = CreateSampleWorkspace(Function='Flat background', NumBanks=1, BankPixelWidth=1, NumEvents=1,
XMin=1, XMax=14, BinWidth=2)
workspace_name = 'workspace'
GroupWorkspaces(InputWorkspaces=['workspace_t0_T1', 'workspace_t1_T2'], OutputWorkspace=workspace_name)
out_name = su.rename_workspace_correctly("SANS2D", su.ReducedType.LAB, "test", workspace_name)
self.assertTrue(AnalysisDataService.doesExist("test_rear"))
self.assertTrue(AnalysisDataService.doesExist("test_t0_T1_rear"))
self.assertTrue(AnalysisDataService.doesExist("test_t1_T2_rear"))
self.assertEqual(out_name, "test_rear")
AnalysisDataService.remove("test_t1_T2_rear")
AnalysisDataService.remove("test_t0_T1_rear")
AnalysisDataService.remove("test_rear")
def test_that_LOQ_workspace_is_renamed_correctly(self):
workspace = self._create_sample_workspace()
out_name = su.rename_workspace_correctly("LOQ", su.ReducedType.LAB, "test", workspace)
workspace_name = workspace.getName()
out_name = su.rename_workspace_correctly("LOQ", su.ReducedType.LAB, "test", workspace_name)
self.assertTrue(AnalysisDataService.doesExist("test_main"))
self.assertTrue(out_name == "test_main")
out_name = su.rename_workspace_correctly("LOQ", su.ReducedType.HAB, "test", workspace)
out_name = su.rename_workspace_correctly("LOQ", su.ReducedType.HAB, "test", out_name)
self.assertTrue(AnalysisDataService.doesExist("test_hab"))
self.assertTrue(out_name == "test_hab")
out_name = su.rename_workspace_correctly("LOQ", su.ReducedType.Merged, "test", workspace)
out_name = su.rename_workspace_correctly("LOQ", su.ReducedType.Merged, "test", out_name)
self.assertTrue(AnalysisDataService.doesExist("test_merged"))
self.assertTrue(out_name == "test_merged")
......@@ -1663,7 +1683,9 @@ class TestRenamingOfBatchModeWorkspaces(unittest.TestCase):
def test_that_LAMROR_workspace_is_not_renamed(self):
workspace = self._create_sample_workspace()
out_name = su.rename_workspace_correctly("LARMOR", su.ReducedType.LAB, "test", workspace)
workspace_name = workspace.getName()
out_name = su.rename_workspace_correctly("LARMOR", su.ReducedType.LAB, "test", workspace_name)
self.assertTrue(AnalysisDataService.doesExist("test"))
self.assertTrue(out_name == "test")
......@@ -1672,8 +1694,11 @@ class TestRenamingOfBatchModeWorkspaces(unittest.TestCase):
def test_that_raies_for_unkown_reduction_type(self):
workspace = self._create_sample_workspace()
args = ["SANS2D", "jsdlkfsldkfj", "test", workspace]
workspace_name = workspace.getName()
args = ["SANS2D", "jsdlkfsldkfj", "test", workspace_name]
self.assertRaises(RuntimeError, su.rename_workspace_correctly, *args)
AnalysisDataService.remove("ws")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment