Commit 34f81e6c authored by Matt Cumber's avatar Matt Cumber
Browse files

Re #30905 Code Clean Up

parent a541d736
......@@ -76,7 +76,6 @@ protected:
Mantid::API::Algorithm_sptr createSampleLogAlgorithm(DataObjects::Workspace2D_sptr &ws);
void addToSampleLog(const std::string &logName, const int logNumber, DataObjects::Workspace2D_sptr &ws);
void addToSampleLog(const std::string &logName, const std::string log, DataObjects::Workspace2D_sptr &ws);
void addToSampleLog(const std::string &logName, const std::vector<int> logs, DataObjects::Workspace2D_sptr &ws);
/// The name and path of the input file
std::string m_filename;
......@@ -92,8 +91,6 @@ protected:
specnum_t m_numberOfSpectra;
/// The number of periods in the raw file
int64_t m_numberOfPeriods;
/// The different pieces of information about periods
std::vector<std::string> m_periodInformation;
/// Has the spectrum_list property been set?
bool m_list;
/// Have the spectrum_min/max properties been set?
......
......@@ -173,7 +173,7 @@ int LoadMuonNexus::confidence(Kernel::NexusDescriptor &descriptor) const {
}
/**
*
* Create Algorithm to add a sample log to a workspace
*/
Mantid::API::Algorithm_sptr LoadMuonNexus::createSampleLogAlgorithm(DataObjects::Workspace2D_sptr &ws) {
Mantid::API::Algorithm_sptr logAlg = createChildAlgorithm("AddSampleLog");
......@@ -182,6 +182,7 @@ Mantid::API::Algorithm_sptr LoadMuonNexus::createSampleLogAlgorithm(DataObjects:
}
/**
* Function to add a single int as a sample log to a workspace
*/
void LoadMuonNexus::addToSampleLog(const std::string &logName, const int logNumber, DataObjects::Workspace2D_sptr &ws) {
auto alg = createSampleLogAlgorithm(ws);
......@@ -192,6 +193,9 @@ void LoadMuonNexus::addToSampleLog(const std::string &logName, const int logNumb
alg->executeAsChildAlg();
}
/**
* Fucntion to add a single string as a sample log to a workspace
*/
void LoadMuonNexus::addToSampleLog(const std::string &logName, const std::string logString,
DataObjects::Workspace2D_sptr &ws) {
auto alg = createSampleLogAlgorithm(ws);
......
......@@ -31,12 +31,11 @@ class DLLExport MuonNexusReader {
@date 14/08/2008
*/
private:
std::string m_nexusInstrumentName; ///< name read from nexus file
std::string m_nexusSampleName; ///< sample name read from Nexus
int m_nexusLogCount; ///< number of NXlog sections read from file
std::vector<bool> m_logType; ///< true if i'th log is numeric
std::vector<std::string> m_logNames; ///< stores name read from file
std::vector<std::string> m_periodInformation; ///< stores the information of the periods
std::string m_nexusInstrumentName; ///< name read from nexus file
std::string m_nexusSampleName; ///< sample name read from Nexus
int m_nexusLogCount; ///< number of NXlog sections read from file
std::vector<bool> m_logType; ///< true if i'th log is numeric
std::vector<std::string> m_logNames; ///< stores name read from file
void openFirstNXentry(NeXus::File &handle);
bool readMuonLogData(NeXus::File &handle); ///< method to read the fields of open NXlog section
std::vector<std::vector<float>> m_logValues, ///< array of values for i'th NXlog section
......@@ -96,12 +95,11 @@ public:
int t_ntc1; ///< number of time channels in time regime 1
int t_nper; ///< number of periods in file (=1 at present)
// for nexus histogram data
std::vector<float> m_correctedTimes; ///< temp store for corrected times
std::vector<int> m_counts; ///< temp store of histogram data
std::vector<int> m_detectorGroupings; ///< detector grouping info
int m_numDetectors; ///< detector count
std::string getInstrumentName() const; ///< return instrument name
std::vector<std::string> getPeriodInfo() const; /// Return period information
std::vector<float> m_correctedTimes; ///< temp store for corrected times
std::vector<int> m_counts; ///< temp store of histogram data
std::vector<int> m_detectorGroupings; ///< detector grouping info
int m_numDetectors; ///< detector count
std::string getInstrumentName() const; ///< return instrument name
int m_numPeriodSequences;
std::string m_periodNames;
std::string m_periodTypes;
......
......@@ -6,9 +6,6 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidNexus/MuonNexusReader.h"
#include "MantidKernel/System.h"
#include <array>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/scoped_array.hpp>
#include <nexus/NeXusException.hpp>
#include <sstream>
......@@ -29,13 +26,7 @@ const string START_TIME("start_time");
/// logger
Mantid::Kernel::Logger g_log("MuonNexusReader");
///< Types for period information
const std::array<std::string, 1> PERIOD_INFO_INT{"period_sequences"};
const std::array<std::string, 4> PERIOD_INFO_INT_ARRAY{"period_type", "frames_period_requested", "frames_period_raw",
"period_output"};
const std::array<std::string, 1> PERIOD_INFO_FLOAT_ARRAY{"total_counts_period"};
const std::array<std::string, 1> PERIOD_INFO_STRING{"period_labels"};
///< Strings for period information
const std::string PERIOD_SEQUENCES("period_sequences");
const std::string PERIOD_TYPE("period_type");
const std::string FRAMES_PERIOD_REQUESTED("frames_period_requested");
......@@ -171,11 +162,6 @@ void MuonNexusReader::readFromFile(const string &filename) {
* - Raw frames
* - Tag
* - Total counts per period
* const std::array<std::string, 1> PERIOD_INFO_INT{"period_sequences"};
const std::array<std::string, 4> PERIOD_INFO_INT_ARRAY{"period_type", "frames_period_requested", "frames_period_raw",
"period_output"};
const std::array<std::string, 1> PERIOD_INFO_FLOAT_ARRAY{"total_counts_period"};
const std::array<std::string, 1> PERIOD_INFO_STRING{"period_labels"};
*/
void MuonNexusReader::readPeriodInfo(NeXus::File &handle) {
int tempInt;
......@@ -405,5 +391,3 @@ bool MuonNexusReader::logTypeNumeric(const int i) const { return (m_logType[i]);
* @return the log name at the given index
*/
string MuonNexusReader::getLogName(const int i) const { return (m_logNames[i]); }
std::vector<std::string> MuonNexusReader::getPeriodInfo() const { return m_periodInformation; }
......@@ -79,7 +79,6 @@ class MuonDataContext(object):
self.instrumentNotifier = MuonDataContext.InstrumentNotifier(self)
self.message_notifier = MuonDataContext.MessageNotifier(self)
self.base_directory = base_directory
self.periods_info = []
def is_data_loaded(self):
return self._loaded_data.num_items() > 0
......@@ -231,7 +230,6 @@ class MuonDataContext(object):
self._loaded_data.clear()
self._current_runs = []
self._main_field_direction = ''
self.periods_info = []
def _base_run_name(self, run=None):
""" e.g. EMU0001234 """
......
......@@ -311,21 +311,6 @@ class GroupingTabPresenter(object):
tags_log = self._model._data.get_sample_log("period_output")
tags = tags_log.value.split(";") if tags_log else []
#
# self.period_info_widget.number_of_sequences = self._model._data.periods_info[0] if \
# self._model._data.periods_info[0] != [''] else None
# names = self._model._data.periods_info[CONTEXT_MAP["Name"]].split(INFO_DELIM) if \
# self._model._data.periods_info[CONTEXT_MAP["Name"]] != [''] else []
# types = self._model._data.periods_info[CONTEXT_MAP["Type"]].split(INFO_DELIM) if \
# self._model._data.periods_info[CONTEXT_MAP["Type"]] != [''] else []
# frames = self._model._data.periods_info[CONTEXT_MAP["Frames"]].split(INFO_DELIM) if \
# self._model._data.periods_info[CONTEXT_MAP["Frames"]] != [''] else []
# total_frames = self._model._data.periods_info[CONTEXT_MAP["Total Good Frames"]].split(INFO_DELIM) if \
# self._model._data.periods_info[CONTEXT_MAP["Total Good Frames"]] != [''] else []
# counts = self._model._data.periods_info[CONTEXT_MAP["Counts"]].split(INFO_DELIM) if \
# self._model._data.periods_info[CONTEXT_MAP["Counts"]] != [''] else []
# tags = self._model._data.periods_info[CONTEXT_MAP["Tag"]].split(INFO_DELIM) if \
# self._model._data.periods_info[CONTEXT_MAP["Tag"]] != [''] else []
names, types, frames, total_frames, counts, tags, count = self._fix_up_period_info_lists([names, types, frames,
total_frames, counts,
tags])
......
......@@ -48,7 +48,7 @@ class BrowseFileWidgetModel(object):
failed_files = []
for filename in self._filenames:
try:
ws, run, filename, psi_data, _ = load_utils.load_workspace_from_filename(filename)
ws, run, filename, psi_data = load_utils.load_workspace_from_filename(filename)
except Exception as error:
failed_files += [(filename, error)]
continue
......
......@@ -31,8 +31,7 @@ class LoadRunWidgetModel(object):
failed_files = []
for filename in self._filenames:
try:
ws, run, filename, _, period_info = load_utils.load_workspace_from_filename(filename)
self._data_context.periods_info = period_info
ws, run, filename, _ = load_utils.load_workspace_from_filename(filename)
except ValueError as error:
failed_files += [(filename, error)]
continue
......
......@@ -23,7 +23,6 @@ NOT_DAQ_STRING = "-"
DAQ = "1"
DWELL = "2"
CYCLES_NOT_FOUND = "Number of period cycles not found"
INFO_DELIM = ';'
class MuonPeriodInfoWidget(QtWidgets.QWidget):
......
......@@ -8,8 +8,6 @@ from mantid.simpleapi import CreateWorkspace
from Muon.GUI.Common.ADSHandler.muon_workspace_wrapper import MuonWorkspaceWrapper
from Muon.GUI.Common.muon_group import MuonGroup
EMPTY_PERIOD_INFO_LIST = ["", "", "", "", "", "", ""]
def create_workspace_wrapper_stub_object(name):
workspace = CreateWorkspace([0], [0])
......
......@@ -179,7 +179,7 @@ def load_dead_time_from_filename(filename):
:param filename: The full path to the .nxs file.
:return: The name of the workspace in the ADS.
"""
loaded_data, run, _, _, _ = load_workspace_from_filename(filename)
loaded_data, run, _, _ = load_workspace_from_filename(filename)
if is_workspace_group(loaded_data["OutputWorkspace"]):
dead_times = loaded_data["DataDeadTimeTable"][0]
......@@ -232,7 +232,7 @@ def load_workspace_from_filename(filename,
load_result["DeadTimeTable"] = None
load_result["FirstGoodData"] = round(load_result["FirstGoodData"] - load_result['TimeZero'], 3)
return load_result, run, filename, psi_data, alg.getProperty("PeriodsInformation").value
return load_result, run, filename, psi_data
def empty_loaded_data():
......
......@@ -73,7 +73,7 @@ class WorkspaceNamingTest(unittest.TestCase):
ConfigService['MantidOptions.InvisibleWorkspaces'] = 'True'
filepath = FileFinder.findRuns('EMU00019489.nxs')[0]
load_result, run_number, filename, psi_data, _ = load_workspace_from_filename(filepath)
load_result, run_number, filename, psi_data = load_workspace_from_filename(filepath)
context = setup_context()
context.gui_context.update({'RebinType': 'None'})
......
......@@ -55,7 +55,7 @@ class FFTPresenterTest(unittest.TestCase):
self.view, self.model, self.context)
file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
ws, run, filename, _, _ = load_utils.load_workspace_from_filename(file_path)
ws, run, filename, _ = load_utils.load_workspace_from_filename(file_path)
self.context.data_context._loaded_data.remove_data(run=run)
self.context.data_context._loaded_data.add_data(run=[run], workspace=ws, filename=filename, instrument='MUSR')
self.context.data_context.current_runs = [[22725]]
......
......@@ -39,7 +39,6 @@ def diff_name():
return name
#
def perform_musr_file_finder(self):
ConfigService['default.instrument'] = 'MUSR'
file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
......@@ -319,8 +318,6 @@ class GroupingTabPresenterTest(unittest.TestCase):
def test_periods_button_data_added_successfully(self):
self.presenter._model.is_data_loaded = mock.Mock(return_value=True)
self.presenter._model._data.periods_info = ["70", "state 1;state 1 dwell", "1;2",
"100;10", "1000;200", "25", "1;2"]
self.presenter._add_period_info_to_widget = mock.MagicMock()
self.presenter.period_info_widget.show = mock.MagicMock()
......@@ -331,8 +328,7 @@ class GroupingTabPresenterTest(unittest.TestCase):
def test_periods_button_data_missing_added_successfully(self):
self.presenter._model.is_data_loaded = mock.Mock(return_value=True)
self.presenter._model._data.periods_info = ["70", "state 1;state 1 dwell", "",
"100;10", "", "", ""]
self.model._data.get_sample_log = mock.Mock(return_value=None)
self.presenter._add_period_info_to_widget = mock.MagicMock()
self.presenter.period_info_widget.show = mock.MagicMock()
......@@ -342,7 +338,7 @@ class GroupingTabPresenterTest(unittest.TestCase):
self.assertEqual(1, self.presenter.period_info_widget.show.call_count)
def test_period_info_corrected_as_expected(self):
info_list = [["state 1", "state 1 dwell"], [""], ["100", "10"], ["1000"], [""], ["1"]]
info_list = [["state 1", "state 1 dwell"], [], ["100", "10"], ["1000"], [], ["1"]]
expected_result = [["state 1", "state 1 dwell"], [PERIOD_INFO_NOT_FOUND, PERIOD_INFO_NOT_FOUND], ["100", "10"],
["1000", PERIOD_INFO_NOT_FOUND], [PERIOD_INFO_NOT_FOUND, PERIOD_INFO_NOT_FOUND],
["1", PERIOD_INFO_NOT_FOUND]]
......
......@@ -36,7 +36,7 @@ class HomeTabRunInfoPresenterTest(unittest.TestCase):
def test_runinfo_correct(self):
file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
ws, run, filename, _, _ = load_utils.load_workspace_from_filename(file_path)
ws, run, filename, _ = load_utils.load_workspace_from_filename(file_path)
self.data_context._loaded_data.remove_data(run=run)
self.data_context._loaded_data.add_data(run=[run], workspace=ws, filename=filename, instrument='MUSR')
self.data_context.current_runs = [[22725]]
......
......@@ -13,7 +13,6 @@ from Muon.GUI.Common.load_file_widget.model import BrowseFileWidgetModel
from Muon.GUI.Common.load_file_widget.presenter import BrowseFileWidgetPresenter
from Muon.GUI.Common.load_file_widget.view import BrowseFileWidgetView
from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests
from Muon.GUI.Common.test_helpers.general_test_helpers import EMPTY_PERIOD_INFO_LIST
class IteratorWithException:
......@@ -80,7 +79,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
def mock_loading_multiple_files_from_browse(self, runs, workspaces, filenames):
self.view.show_file_browser_and_return_selection = mock.Mock(return_value=filenames)
psi_data = [False] * len(filenames)
self.load_utils_patcher.side_effect = zip(workspaces, runs, filenames, psi_data, EMPTY_PERIOD_INFO_LIST)
self.load_utils_patcher.side_effect = zip(workspaces, runs, filenames, psi_data)
def create_fake_workspace(self, name):
workspace_mock = mock.MagicMock()
......@@ -104,8 +103,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
[1234, 1234],
["C:/dir1/file1.nxs",
"C:/dir2/file2.nxs"],
[False, False],
EMPTY_PERIOD_INFO_LIST))
[False, False]))
self.presenter.on_browse_button_clicked()
self.wait_for_thread(self.presenter._load_thread)
......@@ -122,8 +120,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
[1234, 1234],
["C:/dir1/file1.nxs",
"C:/dir2/file2.nxs"],
[False, False],
EMPTY_PERIOD_INFO_LIST))
[False, False]))
self.view.set_file_edit("C:/dir1/file1.nxs;C:/dir2/file1.nxs;C:/dir2/file2.nxs")
self.presenter.handle_file_changed_by_user()
......@@ -140,8 +137,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
self.load_utils_patcher.side_effect = zip([workspace_1, workspace_2],
[1234, 1234],
["C:/dir1/file1.nxs", "C:/dir1/file2.nxs"],
[False, False],
EMPTY_PERIOD_INFO_LIST)
[False, False])
self.view.show_file_browser_and_return_selection = mock.Mock(
return_value=["C:/dir1/file1.nxs", "C:/dir1/file2.nxs"])
......@@ -160,8 +156,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
workspace_2 = self.create_fake_workspace(2)
self.load_utils_patcher.side_effect = zip([workspace_1, workspace_2], [1234, 1234],
["C:/dir1/file1.nxs", "C:/dir1/file2.nxs"],
[False, False],
EMPTY_PERIOD_INFO_LIST)
[False, False])
self.view.set_file_edit("C:/dir1/file1.nxs;C:/dir1/file2.nxs")
self.presenter.handle_file_changed_by_user()
......@@ -195,8 +190,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
self.load_utils_patcher.side_effect = zip([workspace_1, workspace_2],
[1234, 1235],
["C:/dir1/file1.nxs", "C:/dir2/file2.nxs"],
[False, False],
EMPTY_PERIOD_INFO_LIST)
[False, False])
self.view.set_file_edit("C:/dir1/file1.nxs;C:/dir2/file2.nxs")
self.presenter.handle_file_changed_by_user()
......@@ -226,8 +220,7 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase):
workspace_2 = self.create_fake_workspace(2)
self.load_utils_patcher.side_effect = zip([workspace_2, workspace_1], [1235, 1234],
["C:/dir1/file2.nxs", "C:/dir1/file1.nxs"],
[False, False],
EMPTY_PERIOD_INFO_LIST)
[False, False])
self.view.set_file_edit("C:/dir1/file2.nxs;C:/dir1/file1.nxs")
self.presenter.handle_file_changed_by_user()
......
......@@ -14,7 +14,6 @@ from Muon.GUI.Common.load_file_widget.model import BrowseFileWidgetModel
from Muon.GUI.Common.load_file_widget.presenter import BrowseFileWidgetPresenter
from Muon.GUI.Common.load_file_widget.view import BrowseFileWidgetView
from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests
from Muon.GUI.Common.test_helpers.general_test_helpers import EMPTY_PERIOD_INFO_LIST
@start_qapplication
......@@ -68,7 +67,7 @@ class LoadFileWidgetPresenterTest(unittest.TestCase):
def mock_model_to_load_workspaces(self, workspaces, runs, filenames):
psi_data = [False] * len(filenames)
self.load_utils_patcher.side_effect = zip(workspaces, runs, filenames, psi_data, EMPTY_PERIOD_INFO_LIST)
self.load_utils_patcher.side_effect = zip(workspaces, runs, filenames, psi_data)
def load_workspaces_into_model_and_view_from_browse(self, workspaces, runs, files):
self.mock_model_to_load_workspaces(workspaces, runs, files)
......
......@@ -12,7 +12,6 @@ from mantidqt.utils.qt.testing import start_qapplication
from Muon.GUI.Common.load_run_widget.load_run_model import LoadRunWidgetModel
from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests
from Muon.GUI.Common.utilities.muon_test_helpers import IteratorWithException
from Muon.GUI.Common.test_helpers.general_test_helpers import EMPTY_PERIOD_INFO_LIST
@start_qapplication
......@@ -37,8 +36,7 @@ class LoadRunWidgetModelTest(unittest.TestCase):
def test_execute_successfully_loads_valid_files(self, load_utils_mock):
# Mock the load algorithm
files = [r'EMU00019489.nxs', r'EMU00019490.nxs', r'EMU00019491.nxs']
load_return_vals = [([1, 2, 3], 19489 + i, filename, False, EMPTY_PERIOD_INFO_LIST)
for i, filename in enumerate(files)]
load_return_vals = [([1, 2, 3], 19489 + i, filename, False) for i, filename in enumerate(files)]
load_utils_mock.load_workspace_from_filename = mock.MagicMock()
load_utils_mock.load_workspace_from_filename.side_effect = load_return_vals
......@@ -55,8 +53,7 @@ class LoadRunWidgetModelTest(unittest.TestCase):
@mock.patch('Muon.GUI.Common.load_run_widget.load_run_model.load_utils')
def test_model_is_cleared_correctly(self, load_utils_mock):
files = [r'EMU00019489.nxs', r'EMU00019490.nxs', r'EMU00019491.nxs']
load_return_vals = [([1, 2, 3], filename, 19489 + i, False, EMPTY_PERIOD_INFO_LIST)
for i, filename in enumerate(files)]
load_return_vals = [([1, 2, 3], filename, 19489 + i, False) for i, filename in enumerate(files)]
load_utils_mock.load_workspace_from_filename = mock.Mock()
load_utils_mock.load_workspace_from_filename.side_effect = load_return_vals
......@@ -72,8 +69,7 @@ class LoadRunWidgetModelTest(unittest.TestCase):
@mock.patch('Muon.GUI.Common.load_run_widget.load_run_model.load_utils')
def test_execute_throws_if_one_file_does_not_load_correctly_but_still_loads_other_files(self, load_utils_mock):
files = [r'EMU00019489.nxs', r'EMU00019490.nxs', r'EMU00019491.nxs']
load_return_vals = [([1, 2, 3], 19489 + i, filename, False, EMPTY_PERIOD_INFO_LIST)
for i, filename in enumerate(files)]
load_return_vals = [([1, 2, 3], 19489 + i, filename, False) for i, filename in enumerate(files)]
load_utils_mock.load_workspace_from_filename = mock.MagicMock()
......
......@@ -13,7 +13,6 @@ from Muon.GUI.Common.load_run_widget.load_run_model import LoadRunWidgetModel
from Muon.GUI.Common.load_run_widget.load_run_presenter import LoadRunWidgetPresenter
from Muon.GUI.Common.load_run_widget.load_run_view import LoadRunWidgetView
from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests
from Muon.GUI.Common.test_helpers.general_test_helpers import EMPTY_PERIOD_INFO_LIST
from Muon.GUI.Common.thread_model import ThreadModel, ThreadModelWorker
from mantidqt.utils.qt.testing import start_qapplication
from qtpy.QtWidgets import QApplication, QWidget
......@@ -72,8 +71,7 @@ class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase):
self.model = LoadRunWidgetModel(self.loaded_data, self.context)
self.presenter = LoadRunWidgetPresenter(self.view, self.model)
self.model.load_workspace_from_filename = mock.Mock(return_value=([1, 2, 3], "currentRun.nxs", 1234, False,
EMPTY_PERIOD_INFO_LIST))
self.model.load_workspace_from_filename = mock.Mock(return_value=([1, 2, 3], "currentRun.nxs", 1234, False))
self.view.warning_popup = mock.Mock()
self.view.disable_load_buttons = mock.Mock()
self.view.enable_load_buttons = mock.Mock()
......@@ -98,7 +96,7 @@ class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase):
def test_load_current_run_loads_run_into_model(self):
workspace = self.create_fake_workspace()
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(return_value=(workspace, 1234, "currentRun.nxs"
, False, EMPTY_PERIOD_INFO_LIST))
, False))
self.presenter.handle_load_current_run()
self.wait_for_thread(self.presenter._load_thread)
......@@ -112,7 +110,7 @@ class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase):
def test_load_current_run_correctly_displays_run_if_load_successful(self):
workspace = self.create_fake_workspace()
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(return_value=(workspace, 1234, "1234.nxs",
False, EMPTY_PERIOD_INFO_LIST))
False))
self.presenter.handle_load_current_run()
self.wait_for_thread(self.presenter._load_thread)
......@@ -134,7 +132,7 @@ class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase):
# set up previous data
workspace = self.create_fake_workspace()
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(return_value=(workspace, 1234, "1234.nxs",
False, EMPTY_PERIOD_INFO_LIST))
False))
self.view.set_run_edit_text("1234")
self.presenter.handle_run_changed_by_user()
self.wait_for_thread(self.presenter._load_thread)
......@@ -157,7 +155,7 @@ class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase):
self.wait_for_thread(self.presenter._load_thread)
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(return_value=(workspace, 9999, "9999.nxs",
False, EMPTY_PERIOD_INFO_LIST))
False))
self.presenter.handle_load_current_run()
self.wait_for_thread(self.presenter._load_thread)
......@@ -175,7 +173,7 @@ class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase):
# set up current run
workspace = self.create_fake_workspace()
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(return_value=(workspace, 1234, "1234.nxs",
False, EMPTY_PERIOD_INFO_LIST))
False))
self.view.set_run_edit_text("1234")
self.presenter.handle_load_current_run()
self.wait_for_thread(self.presenter._load_thread)
......
......@@ -15,7 +15,6 @@ from Muon.GUI.Common.load_run_widget.load_run_model import LoadRunWidgetModel
from Muon.GUI.Common.load_run_widget.load_run_presenter import LoadRunWidgetPresenter
from Muon.GUI.Common.load_run_widget.load_run_view import LoadRunWidgetView
from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests
from Muon.GUI.Common.test_helpers.general_test_helpers import EMPTY_PERIOD_INFO_LIST
@start_qapplication
......@@ -63,8 +62,7 @@ class LoadRunWidgetIncrementDecrementSingleFileModeTest(unittest.TestCase):
self._loaded_workspace = {'MainFieldDirection': 'transverse'}
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(
return_value=(self._loaded_workspace, self._loaded_run,
self._loaded_filename, False, EMPTY_PERIOD_INFO_LIST))
return_value=(self._loaded_workspace, self._loaded_run, self._loaded_filename, False))
self.view.set_run_edit_text(str(self._loaded_run))
self.presenter.handle_run_changed_by_user()
self.wait_for_thread(self.presenter._load_thread)
......@@ -117,7 +115,7 @@ class LoadRunWidgetIncrementDecrementSingleFileModeTest(unittest.TestCase):
new_run = self._loaded_run - 1
new_filename = "EMU00001233.nxs"
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(
return_value=({'MainFieldDirection': 'transverse'}, new_run, new_filename, False, EMPTY_PERIOD_INFO_LIST))
return_value=({'MainFieldDirection': 'transverse'}, new_run, new_filename, False))
self.presenter.handle_decrement_run()
self.wait_for_thread(self.presenter._load_thread)
......@@ -133,7 +131,7 @@ class LoadRunWidgetIncrementDecrementSingleFileModeTest(unittest.TestCase):
new_run = self._loaded_run + 1
new_filename = "EMU00001235.nxs"
self.load_utils_patcher.load_workspace_from_filename = mock.Mock(
return_value=({'MainFieldDirection': 'transverse'}, new_run, new_filename, False, EMPTY_PERIOD_INFO_LIST))
return_value=({'MainFieldDirection': 'transverse'}, new_run, new_filename, False))
self.presenter.handle_increment_run()
self.wait_for_thread(self.presenter._load_thread)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment