Skip to content

Commit

Permalink
Update failing tests after introducing AlgorithmRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
robertapplin committed May 9, 2024
1 parent 34aa777 commit 5acf1cd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 47 deletions.
Expand Up @@ -31,8 +31,7 @@ DataReductionTab::DataReductionTab(IDataReduction *idrUI, QObject *parent)
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(handleNewInstrumentConfiguration()));
}

DataReductionTab::DataReductionTab(IDataReduction *idrUI,
std::unique_ptr<API::IAlgorithmRunner> algorithmRunner)
DataReductionTab::DataReductionTab(IDataReduction *idrUI, std::unique_ptr<API::IAlgorithmRunner> algorithmRunner)
: InelasticTab(), m_idrUI(idrUI), m_tabRunning(false), m_algorithmRunner(std::move(algorithmRunner)) {
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(tabExecutionComplete(bool)));
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(handleNewInstrumentConfiguration()));
Expand Down Expand Up @@ -83,7 +82,7 @@ void DataReductionTab::tabExecutionComplete(bool error) {
}
}

void IndirectDataReductionTab::handleNewInstrumentConfiguration() { updateInstrumentConfiguration(); }
void DataReductionTab::handleNewInstrumentConfiguration() { updateInstrumentConfiguration(); }

/**
* Gets the current instrument workspace
Expand Down
Expand Up @@ -310,9 +310,7 @@ class ISISEnergyTransferModelTest : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(outputName, "instrument1234, 1235_analyser_reflection_Reduced");
}

void testRunIETAlgorithm() {
MantidQt::API::BatchAlgorithmRunner *batch = new MantidQt::API::BatchAlgorithmRunner(nullptr);

void test_energyTransferAlgorithm() {
IETInputData inputData("input_workspace1, input_workspace2", "input_workspace1, input_workspace2", true, false,
true, "calibration_workspace");
IETConversionData conversionData(1.0, 1, 2);
Expand All @@ -327,43 +325,18 @@ class ISISEnergyTransferModelTest : public CxxTest::TestSuite {

InstrumentData instData("instrument", "analyser", "reflection");

m_model->runIETAlgorithm(batch, instData, runData);

// Wait for the algorithm to finish
std::this_thread::sleep_for(std::chrono::seconds(1));

TS_ASSERT_EQUALS(AnalysisDataService::Instance().doesExist("outputWS"), true);
if (AnalysisDataService::Instance().doesExist("outputWS")) {
ITableWorkspace_sptr outputWS =
Mantid::API::AnalysisDataService::Instance().retrieveWS<Mantid::DataObjects::TableWorkspace>("outputWS");

TS_ASSERT_EQUALS(outputWS->rowCount(), 1);
TS_ASSERT_EQUALS(outputWS->columnCount(), 18);

TS_ASSERT_EQUALS(outputWS->getColumn(0)->name(), "Instrument");
TS_ASSERT_EQUALS(outputWS->getColumn(1)->name(), "Analyser");
TS_ASSERT_EQUALS(outputWS->getColumn(2)->name(), "Reflection");
auto configuredAlg = m_model->energyTransferAlgorithm(instData, runData);
auto &runtimeProps = configuredAlg->getAlgorithmRuntimeProps();
TS_ASSERT_EQUALS("instrument", runtimeProps.getPropertyValue("Instrument"));
TS_ASSERT_EQUALS("analyser", runtimeProps.getPropertyValue("Analyser"));
TS_ASSERT_EQUALS("reflection", runtimeProps.getPropertyValue("Reflection"));

TS_ASSERT_EQUALS(outputWS->getColumn(3)->name(), "InputFiles");
TS_ASSERT_EQUALS(outputWS->getColumn(4)->name(), "SumFiles");
TS_ASSERT_EQUALS(outputWS->getColumn(5)->name(), "LoadLogFiles");
TS_ASSERT_EQUALS(outputWS->getColumn(6)->name(), "CalibrationWorkspace");
TS_ASSERT_EQUALS("input_workspace1, input_workspace2", runtimeProps.getPropertyValue("InputFiles"));
TS_ASSERT_EQUALS("1", runtimeProps.getPropertyValue("SumFiles"));
TS_ASSERT_EQUALS("0", runtimeProps.getPropertyValue("LoadLogFiles"));

TS_ASSERT_EQUALS(outputWS->getColumn(7)->name(), "Efixed");
TS_ASSERT_EQUALS(outputWS->getColumn(8)->name(), "SpectraRange");
TS_ASSERT_EQUALS(outputWS->getColumn(9)->name(), "BackgroundRange");
TS_ASSERT_EQUALS(outputWS->getColumn(10)->name(), "RebinString");

TS_ASSERT_EQUALS(outputWS->getColumn(11)->name(), "DetailedBalance");

TS_ASSERT_EQUALS(outputWS->getColumn(12)->name(), "UnitX");
TS_ASSERT_EQUALS(outputWS->getColumn(13)->name(), "FoldMultipleFrames");
TS_ASSERT_EQUALS(outputWS->getColumn(14)->name(), "OutputWorkspace");

TS_ASSERT_EQUALS(outputWS->getColumn(15)->name(), "GroupingMethod");
TS_ASSERT_EQUALS(outputWS->getColumn(16)->name(), "GroupingString");
TS_ASSERT_EQUALS(outputWS->getColumn(17)->name(), "GroupingFile");
}
TS_ASSERT_EQUALS("1, 2", runtimeProps.getPropertyValue("SpectraRange"));
TS_ASSERT_EQUALS("0, 1", runtimeProps.getPropertyValue("BackgroundRange"));
}

void testValidateRunDetailedBalanceInvalid() {
Expand Down
Expand Up @@ -16,6 +16,7 @@

#include "MantidFrameworkTestHelpers/IndirectFitDataCreationHelper.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidQtWidgets/Common/MockAlgorithmRunner.h"

using namespace MantidQt::CustomInterfaces;
using namespace testing;
Expand All @@ -33,6 +34,7 @@ class ISISEnergyTransferPresenterTest : public CxxTest::TestSuite {

void setUp() override {
auto model = std::make_unique<NiceMock<MockIETModel>>();
auto algorithmRunner = std::make_unique<NiceMock<MockAlgorithmRunner>>();

m_outputOptionsView = std::make_unique<NiceMock<MockOutputPlotOptionsView>>();
m_instrumentConfig = std::make_unique<NiceMock<MockInstrumentConfig>>();
Expand All @@ -41,17 +43,20 @@ class ISISEnergyTransferPresenterTest : public CxxTest::TestSuite {
ON_CALL(*m_view, getPlotOptionsView()).WillByDefault(Return(m_outputOptionsView.get()));

m_model = model.get();
m_algorithmRunner = algorithmRunner.get();
m_idrUI = std::make_unique<NiceMock<MockDataReduction>>();
ON_CALL(*m_idrUI, getInstrumentConfiguration()).WillByDefault(Return(m_instrumentConfig.get()));

m_presenter = std::make_unique<IETPresenter>(m_idrUI.get(), m_view.get(), std::move(model));
m_presenter =
std::make_unique<IETPresenter>(m_idrUI.get(), m_view.get(), std::move(model), std::move(algorithmRunner));
}

void tearDown() override {
TS_ASSERT(Mock::VerifyAndClearExpectations(&m_outputOptionsView));
TS_ASSERT(Mock::VerifyAndClearExpectations(&m_instrumentConfig));
TS_ASSERT(Mock::VerifyAndClearExpectations(&m_view));
TS_ASSERT(Mock::VerifyAndClearExpectations(m_model));
TS_ASSERT(Mock::VerifyAndClearExpectations(m_algorithmRunner));
TS_ASSERT(Mock::VerifyAndClearExpectations(&m_idrUI));

m_presenter.reset();
Expand Down Expand Up @@ -116,6 +121,7 @@ class ISISEnergyTransferPresenterTest : public CxxTest::TestSuite {

std::unique_ptr<NiceMock<MockIETView>> m_view;
NiceMock<MockIETModel> *m_model;
NiceMock<MockAlgorithmRunner> *m_algorithmRunner;
std::unique_ptr<NiceMock<MockDataReduction>> m_idrUI;

std::unique_ptr<NiceMock<MockOutputPlotOptionsView>> m_outputOptionsView;
Expand Down
Expand Up @@ -44,8 +44,8 @@ class MockIETModel : public IIETModel {
MOCK_METHOD1(validateRunData, std::vector<std::string>(IETRunData const &runData));
MOCK_METHOD1(validatePlotData, std::vector<std::string>(IETPlotData const &plotData));

MOCK_METHOD3(runIETAlgorithm, std::string(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner,
InstrumentData const &instData, IETRunData &runParams));
MOCK_METHOD2(energyTransferAlgorithm,
MantidQt::API::IConfiguredAlgorithm_sptr(InstrumentData const &instData, IETRunData &runParams));
MOCK_CONST_METHOD2(plotRawAlgorithmQueue,
std::deque<MantidQt::API::IConfiguredAlgorithm_sptr>(InstrumentData const &instData,
IETPlotData const &plotData));
Expand All @@ -60,6 +60,7 @@ class MockIETModel : public IIETModel {
MOCK_METHOD4(groupWorkspaces, std::vector<std::string>(std::string const &groupName, std::string const &instrument,
std::string const &groupOption, bool const shouldGroup));

MOCK_CONST_METHOD0(outputGroupName, std::string());
MOCK_CONST_METHOD0(outputWorkspaceNames, std::vector<std::string>());
};

Expand Down
3 changes: 0 additions & 3 deletions qt/widgets/common/CMakeLists.txt
Expand Up @@ -5,7 +5,6 @@ set(SRC_FILES
src/AlgorithmHistoryWindow.cpp
src/AlgorithmInputHistory.cpp
src/AlgorithmPropertiesWidget.cpp
src/AlgorithmRunner.cpp
src/AlgorithmSelectorWidget.cpp
src/AlgorithmRunner.cpp
src/AlternateCSPythonLexer.cpp
Expand Down Expand Up @@ -391,7 +390,6 @@ set(MOC_FILES
inc/MantidQtWidgets/Common/OptionsPropertyWidget.h
inc/MantidQtWidgets/Common/PropertyWidget.h
inc/MantidQtWidgets/Common/PythonRunner.h
inc/MantidQtWidgets/Common/QtAlgorithmRunner.h
inc/MantidQtWidgets/Common/QScienceSpinBox.h
inc/MantidQtWidgets/Common/QtSignalChannel.h
inc/MantidQtWidgets/Common/RepoTreeView.h
Expand Down Expand Up @@ -523,7 +521,6 @@ set(INC_FILES
inc/MantidQtWidgets/Common/QtAlgorithmRunner.h
inc/MantidQtWidgets/Common/QSettingsHelper.h
inc/MantidQtWidgets/Common/QStringUtils.h
inc/MantidQtWidgets/Common/QtAlgorithmRunner.h
inc/MantidQtWidgets/Common/QtJSONUtils.h
inc/MantidQtWidgets/Common/ScriptRepositoryView.h
inc/MantidQtWidgets/Common/SelectionNotificationService.h
Expand Down

0 comments on commit 5acf1cd

Please sign in to comment.