From 332f971dc7afa25dd6d127f5a20f43076f7e7031 Mon Sep 17 00:00:00 2001
From: David Fairbrother <DavidFair@users.noreply.github.com>
Date: Mon, 9 Jan 2017 11:12:18 +0000
Subject: [PATCH] Re #18108 Remove old unit tests and update sys test

---
 .../tests/analysis/ISIS_PowderPearlTest.py    |  2 +-
 .../tests/analysis/ISIS_PowderPolarisTest.py  |  2 +-
 ...SIS_PowderPEARL95634-95647_Van_Cal.nxs.md5 |  2 +-
 .../isis_powder/mock_instrument.py            | 42 ++-------
 .../isis_powder/pearl_routines/pearl_algs.py  |  1 -
 scripts/test/ISIS_Powder_AbstractInstTest.py  | 89 -------------------
 scripts/test/ISIS_Powder_PearlTest.py         | 71 ---------------
 7 files changed, 11 insertions(+), 198 deletions(-)
 delete mode 100644 scripts/test/ISIS_Powder_AbstractInstTest.py
 delete mode 100644 scripts/test/ISIS_Powder_PearlTest.py

diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py
index b0a4a85b416..df2048edc0d 100644
--- a/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py
+++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py
@@ -65,7 +65,7 @@ def _get_input_dir():
 
 
 def _get_output_dir():
-    return os.path.join(DIRS[0], "PEARL", "SystemTestOutput")
+    return os.path.join(DIRS[0], "PEARL", "SystemTest_Output")
 
 
 def _run_vanadium_calibration():
diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py
index 41042f8f4f9..75d2788cc4a 100644
--- a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py
+++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py
@@ -72,7 +72,7 @@ def _run_vanadium_calibration():
 def _run_focus():
     run_number = 95599
     polaris_obj = setup_polaris_instrument()
-    return polaris_obj.focus(run_number=run_number, input_mode="Individual")
+    return polaris_obj.focus(run_number=run_number, input_mode="Individual", do_van_normalisation=True)
 
 
 def _calibration_validation(cls, results):
diff --git a/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5
index 42890acecb3..f50b06c6be5 100644
--- a/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5
+++ b/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5
@@ -1 +1 @@
-3bca903e6dc91cd658c01efc75e5881a
+35cbcc39432281c90c97e36bd6be7e1f
diff --git a/scripts/Diffraction/isis_powder/mock_instrument.py b/scripts/Diffraction/isis_powder/mock_instrument.py
index a44b02a5c2e..201746fb420 100644
--- a/scripts/Diffraction/isis_powder/mock_instrument.py
+++ b/scripts/Diffraction/isis_powder/mock_instrument.py
@@ -1,48 +1,22 @@
 from isis_powder.abstract_inst import AbstractInst
+from isis_powder.routines import RunDetails
 
 
 class MockInstrument(AbstractInst):
 
-    def __init__(self, user_name, calibration_dir, output_dir, default_ext=""):
+    def __init__(self, user_name, calibration_dir, output_dir):
         super(MockInstrument, self).__init__(user_name=user_name, calibration_dir=calibration_dir,
-                                             output_dir=output_dir, default_input_ext=default_ext)
+                                             output_dir=output_dir)
         self.generate_cycle_dir_flag = False
 
-    def _get_lambda_range(self):
-        return None
-
-    def _get_focus_tof_binning(self):
-        return None
+    def generate_output_file_name(self, run_number_string):
+        return "test_output_string"
 
-    def get_create_van_tof_binning(self):
+    def generate_vanadium_absorb_corrections(self, calibration_full_paths, ws_to_match):
         return None
 
-    def get_default_group_names(self):
+    def spline_vanadium_ws(self, focused_vanadium_banks):
         return None
 
     def get_run_details(self, run_number_string):
-        # This is here to help remind people of the dict that is expected
-        calibration_details = {"calibration": "cal",
-                               "grouping": "group",
-                               "vanadium_absorption": "van_absorb",
-                               "vanadium": "van"}
-        return calibration_details
-
-    @staticmethod
-    def generate_input_file_name(run_number):
-        return "generate_inst_file_name" + str(run_number)
-
-    @staticmethod
-    def get_num_of_banks(instrument=''):
-        return None
-
-    @staticmethod
-    def _get_label_information(run_number):
-        # This is here to help remind people of the dict format
-        cycle_information = {"cycle" : "123",
-                             "instrument_version": "test_v1"}
-        return cycle_information
-
-    def test_set_raw_data_dir(self, new_dir):
-        # Used for testing to set a new raw_data_dir
-        self._raw_data_dir = new_dir
+        return RunDetails.RunDetails(run_number=run_number_string)
diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py
index a36ae9421db..c9670a80dab 100644
--- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py
+++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py
@@ -6,7 +6,6 @@ import mantid.simpleapi as mantid
 import isis_powder.routines.common as common
 from isis_powder.routines import yaml_parser
 from isis_powder.routines.RunDetails import RunDetails
-from isis_powder.pearl_routines import pearl_advanced_config
 
 
 def attenuate_workspace(attenuation_file_path, ws_to_correct):
diff --git a/scripts/test/ISIS_Powder_AbstractInstTest.py b/scripts/test/ISIS_Powder_AbstractInstTest.py
deleted file mode 100644
index 27911d7f871..00000000000
--- a/scripts/test/ISIS_Powder_AbstractInstTest.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import unittest
-
-import mantid as mantid  # For next import to work
-from isis_powder.mock_instrument import MockInstrument
-import os
-
-
-class isis_powder_AbstractInstTest(unittest.TestCase):
-
-    def test_init_sets_params(self):
-        inst = self._get_abstract_inst_all_specified()
-
-        # Default Params
-
-        self.assertEquals(inst.calibration_dir, self.calibration_dir)
-        self.assertEquals(inst.output_dir, self.output_dir)
-
-        # Optional Params
-        self.assertEquals(inst.default_input_ext, self.default_ext)
-
-
-    def test_generate_full_input_path(self):
-        inst = self._get_abstract_inst_all_specified()
-        run_number = 12345
-        inst_file_name = inst.generate_input_file_name(run_number)
-        input_path = "test"
-        reference_output = os.path.join(input_path, (inst_file_name + self.default_ext))
-
-        output = inst._generate_input_full_path(run_number, input_path)
-        self.assertEquals(output, reference_output)
-
-    # Test empty hooks work correctly
-    def test_attenuate_workspace_hook(self):
-        inst = self._get_abstract_inst_defaults()
-        input_ws = "ws_in"
-
-        output_ws = inst.attenuate_workspace(input_ws)
-        self.assertEquals(input_ws, output_ws)
-
-    def test_create_calibration_si(self):
-        inst = self._get_abstract_inst_defaults()
-        self.assertRaises(NotImplementedError, lambda: inst._create_calibration_silicon("", "", ""))
-
-    def test_create_calibration(self):
-        inst = self._get_abstract_inst_defaults()
-        self.assertRaises(NotImplementedError, lambda: inst.create_calibration("", "", ""))
-
-    def test_get_monitor_spectra_hook(self):
-        inst = self._get_abstract_inst_defaults()
-        unused_param = None
-        output = inst.get_monitor_spectra_index(unused_param)
-
-        # Should return empty string
-        self.assertEquals(output, str(""))
-
-    def test_spline_background_hook(self):
-        inst = self._get_abstract_inst_defaults()
-        # Use type this isn't None to make sure its not returning to us
-        unused_param = "unused"
-        output = inst.spline_vanadium_ws(unused_param, unused_param, unused_param)
-
-        self.assertEquals(isinstance(output, type(None)), True)
-
-    # Helper methods to create fresh instrument objects
-
-    def _get_abstract_inst_defaults(self):
-        return MockInstrument(user_name=self.user_name, calibration_dir=self.calibration_dir,
-                              output_dir=self.output_dir)
-    
-    def _get_abstract_inst_all_specified(self):
-        return MockInstrument(user_name=self.user_name, calibration_dir=self.calibration_dir,
-                              output_dir=self.output_dir, default_ext=self.default_ext)
-
-    # Test params
-    user_name = "unit_test_abstract_inst"
-    calibration_dir = "calDir"
-    output_dir = "outDir"
-
-    # Optional Params
-    default_ext = ".ext"
-
-
-if __name__ == '__main__':
-    unittest.main()
-
-
-
-
-
diff --git a/scripts/test/ISIS_Powder_PearlTest.py b/scripts/test/ISIS_Powder_PearlTest.py
deleted file mode 100644
index 6b28ba161a6..00000000000
--- a/scripts/test/ISIS_Powder_PearlTest.py
+++ /dev/null
@@ -1,71 +0,0 @@
-from __future__ import (absolute_import, division, print_function)
-
-import os
-import unittest
-
-import mantid as mantid
-from isis_powder import pearl
-
-
-class isis_powder_PearlTest(unittest.TestCase):
-
-    # Static method tests
-
-    def test_cycle_information_generates_correctly(self):
-        # This checks that the cycle information generates using the correct keys for the dict
-        output = self._get_pearl_inst_defaults()._get_label_information(85500)
-        expected_cycle = "14_1"
-        expected_inst_vers = "new2"
-        self.assertEquals(output["cycle"], expected_cycle)
-        self.assertEquals(output["instrument_version"], expected_inst_vers)
-
-    def test_get_instrument_ranges(self):
-        # This test checks that the instrument ranges calculate correctly for given instruments
-        # First the "new" instrument value
-        new_alg_range, new_save_range = pearl._get_instrument_ranges("new")
-        self.assertEquals(new_alg_range, 12, "'new' instrument algorithm range got " + str(new_alg_range))
-        self.assertEquals(new_save_range, 3, "'new' instrument save range got " + str(new_save_range))
-
-        new2_alg_range, new2_save_range = pearl._get_instrument_ranges("new2")
-        self.assertEquals(new2_alg_range, 14, "'new2' instrument algorithm range got " + str(new2_alg_range))
-        self.assertEquals(new2_save_range, 5, "'new2' instrument save range got " + str(new2_save_range))
-
-    def test_generate_inst_file_name(self):
-        # Tests that the generated names conform to the format expected
-        old_name_input = 71008  # This is the last run to use the old format
-        new_name_input = 71009  # Everything after this run should use new format
-
-        expected_old_name = "PRL" + str(old_name_input)
-        expected_new_name = "PEARL" + "000" + str(new_name_input)  # New names should have 8 numerical digits
-
-        old_output = pearl._gen_file_name(old_name_input)
-        self.assertEquals(expected_old_name, old_output)
-
-        new_output = pearl._gen_file_name(new_name_input)
-        self.assertEquals(expected_new_name, new_output)
-
-    # Non static methods
-    def _get_pearl_inst_defaults(self):
-        return pearl.Pearl(user_name="unitTest-PEARL", calibration_dir=self.calibration_dir,
-                           raw_data_dir=self.raw_data_dir, output_dir=self.output_dir)
-
-    def _get_pearl_inst_all_specified(self):
-        return pearl.Pearl(calibration_dir=self.calibration_dir, raw_data_dir=self.raw_data_dir,
-                           output_dir=self.output_dir, input_file_ext=self.default_ext, tt_mode=self.tt_mode)
-
-    # Test params
-    calibration_dir = "calDir"
-    raw_data_dir = "rawDir"
-    output_dir = "outDir"
-
-    default_tt_mode = "TT88"
-
-    # Optional Params
-    default_ext = ".ext"
-    tt_mode = "tt_test"
-
-
-if __name__ == '__main__':
-    DIRS = mantid.config['datasearch.directories'].split(';')
-    CalibDir = os.path.join(DIRS[0] + '/PEARL/Calibration_Test/Calibration/')
-    unittest.main()
\ No newline at end of file
-- 
GitLab