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 2, 2024
1 parent 1b87504 commit a5b8127
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 41 deletions.
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<MockIndirectDataReduction>>();
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<MockIndirectDataReduction>> 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

0 comments on commit a5b8127

Please sign in to comment.