Skip to content

Commit

Permalink
Refactor system tests to use a common interface
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedAlmaki committed Jun 19, 2023
1 parent f916d1b commit d5c63ca
Showing 1 changed file with 69 additions and 101 deletions.
170 changes: 69 additions & 101 deletions Testing/SystemTests/tests/framework/ISIS_PowderOsirisTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,24 @@ def _try_delete(path):
print("Could not delete output file at: ", path)


class OSIRISDiffractionFocusingWithSubtractionTest(systemtesting.MantidSystemTest):
class _OSIRISDiffractionFocusingTest(systemtesting.MantidSystemTest):
existing_config = config["datasearch.directories"]
refrence_ws_name = None
required_run_files = []

def requiredFiles(self):
return self._gen_required_files()
def skipTests(self):
# Don't actually run this test, as it is a common interface for other tests tests
return True

def runTest(self):
def runPreTest(self):
setup_mantid_paths()
self.results = run_diffraction_focusing(
"119977",
"Test",
"OSI119977_d_spacing.nxs",
subtract_empty_can=True,
)

def requiredFiles(self):
return self._gen_required_files()

def validate(self):
foccussed_ws = self.results
return (foccussed_ws.name(), "OSI119977_d_spacing.nxs")
return (foccussed_ws.name(), self.refrence_ws_name)

def cleanup(self):
try:
Expand All @@ -143,64 +143,68 @@ def cleanup(self):
config["datasearch.directories"] = self.existing_config

def _gen_required_files(self):
required_run_files = [
"OSI82717.nxs", # empty can
"OSIRIS00119963.nxs", # van
"OSIRIS00119977.nxs",
] # sample
input_files = [os.path.join(input_dir, file) for file in required_run_files]
input_files = [os.path.join(input_dir, file) for file in self.required_run_files]
input_files.append(calibration_map_path)
return input_files


class OSIRISDiffractionFocusingWithMergingTest(systemtesting.MantidSystemTest):
existing_config = config["datasearch.directories"]
class OSIRISDiffractionFocusingWithSubtractionTest(_OSIRISDiffractionFocusingTest):
refrence_ws_name = "OSI119977_d_spacing.nxs"
required_run_files = [
"OSI82717.nxs", # empty can
"OSIRIS00119963.nxs", # van
"OSIRIS00119977.nxs",
]

def runTest(self):
super().runPreTest()
self.results = run_diffraction_focusing(
"119977",
"Test",
"OSI119977_d_spacing.nxs",
subtract_empty_can=True,
)

def skipTests(self):
return False

def requiredFiles(self):
return self._gen_required_files()

class OSIRISDiffractionFocusingWithMergingTest(_OSIRISDiffractionFocusingTest):
refrence_ws_name = "OSI119977-119978_d_spacing.nxs"
required_run_files = [
"OSI82717.nxs",
"OSI82718.nxs", # empty can
"OSIRIS00119963.nxs",
"OSIRIS00119964.nxs", # van
"OSIRIS00119977.nxs",
"OSIRIS00119978.nxs",
]

def runTest(self):
setup_mantid_paths()
super().runPreTest()
self.results = run_diffraction_focusing(
"119977-119978",
"Test_Merge",
"OSI119977-119978_d_spacing.nxs",
merge_drange=True,
)

def validate(self):
foccussed_ws = self.results
return (foccussed_ws.name(), "OSI119977-119978_d_spacing.nxs")
def skipTests(self):
return False

def cleanup(self):
try:
_try_delete(output_dir)
finally:
mantid.mtd.clear()
config["datasearch.directories"] = self.existing_config

def _gen_required_files(self):
required_run_files = [
"OSI82717.nxs",
"OSI82718.nxs", # empty can
"OSIRIS00119963.nxs",
"OSIRIS00119964.nxs", # van
"OSIRIS00119977.nxs",
"OSIRIS00119978.nxs",
] # sample
input_files = [os.path.join(input_dir, file) for file in required_run_files]
input_files.append(calibration_map_path)
return input_files


class OSIRISDiffractionFocusingWithSimpleAbsorptionCorrection(systemtesting.MantidSystemTest):
existing_config = config["datasearch.directories"]

def requiredFiles(self):
return self._gen_required_files()
class OSIRISDiffractionFocusingWithSimpleAbsorptionCorrection(_OSIRISDiffractionFocusingTest):
refrence_ws_name = "OSI120032_d_spacing_simple_corrected.nxs"
required_run_files = [
"OSI82717.nxs",
"OSI82718.nxs", # empty can
"OSIRIS00119963.nxs",
"OSIRIS00119964.nxs", # van
"OSIRIS00120032.nxs",
]

def runTest(self):
setup_mantid_paths()
super().runPreTest()
sample_details = SampleDetails(radius=1.1, height=8, center=[0, 0, 0], shape="cylinder")
sample_details.set_material(chemical_formula="Cr2-Ga-N", number_density=10.0)
sample_details.set_container(chemical_formula="Al", number_density=2.7, radius=1.2)
Expand All @@ -216,38 +220,22 @@ def runTest(self):
vanadium_normalization_cutoff=100000000,
)

def validate(self):
foccussed_ws = self.results
return (foccussed_ws.name(), "OSI120032_d_spacing_simple_corrected.nxs")
def skipTests(self):
return False

def cleanup(self):
try:
_try_delete(output_dir)
finally:
mantid.mtd.clear()
config["datasearch.directories"] = self.existing_config

def _gen_required_files(self):
required_run_files = [
"OSI82717.nxs",
"OSI82718.nxs", # empty can
"OSIRIS00119963.nxs",
"OSIRIS00119964.nxs", # van
"OSIRIS00120032.nxs",
] # sample
input_files = [os.path.join(input_dir, file) for file in required_run_files]
input_files.append(calibration_map_path)
return input_files


class OSIRISDiffractionFocusingWithPaalmanPingsAbsorptionCorrection(systemtesting.MantidSystemTest):
existing_config = config["datasearch.directories"]

def requiredFiles(self):
return self._gen_required_files()
class OSIRISDiffractionFocusingWithPaalmanPingsAbsorptionCorrection(_OSIRISDiffractionFocusingTest):
refrence_ws_name = "OSI120032_d_spacing_paalman_corrected.nxs"
required_run_files = [
"OSI82717.nxs",
"OSI82718.nxs", # empty can
"OSIRIS00119963.nxs",
"OSIRIS00119964.nxs", # van
"OSIRIS00120032.nxs",
]

def runTest(self):
setup_mantid_paths()
super().runPreTest()
sample_details = SampleDetails(radius=1.1, height=8, center=[0, 0, 0], shape="cylinder")
sample_details.set_material(chemical_formula="Cr2-Ga-N", number_density=10.0)
sample_details.set_container(chemical_formula="Al", number_density=2.7, radius=1.2)
Expand All @@ -263,25 +251,5 @@ def runTest(self):
vanadium_normalization_cutoff=100000000,
)

def validate(self):
foccussed_ws = self.results
return (foccussed_ws.name(), "OSI120032_d_spacing_paalman_corrected.nxs")

def cleanup(self):
try:
_try_delete(output_dir)
finally:
mantid.mtd.clear()
config["datasearch.directories"] = self.existing_config

def _gen_required_files(self):
required_run_files = [
"OSI82717.nxs",
"OSI82718.nxs", # empty can
"OSIRIS00119963.nxs",
"OSIRIS00119964.nxs", # van
"OSIRIS00120032.nxs",
] # sample
input_files = [os.path.join(input_dir, file) for file in required_run_files]
input_files.append(calibration_map_path)
return input_files
def skipTests(self):
return False

0 comments on commit d5c63ca

Please sign in to comment.