Skip to content
Snippets Groups Projects
Commit 94fd90bb authored by Gemma Guest's avatar Gemma Guest
Browse files

Add unit tests for new behaviour

Changed behaviour:

- Minor change to some tests to add Debug flag to ensure that IvsLam outputs that are being checked are actually created. For group workspaces this is currently true anyway at the moment but might not be going forward.

Add new unit tests:

- Check default output names are correct.
- Check that user can override default names.
- Check both with and without debug outputs.

Also fixed ambiguous overload in reflectometry helpers.

Re #24564
parent e3f6ded6
No related branches found
No related tags found
No related merge requests found
...@@ -876,6 +876,85 @@ public: ...@@ -876,6 +876,85 @@ public:
ADS.clear(); ADS.clear();
} }
void test_input_workspace_group_with_default_output_workspaces() {
ReflectometryReductionOneAuto2 alg;
setup_alg_on_input_workspace_group_with_run_number(alg);
TS_ASSERT_THROWS_NOTHING(alg.execute());
// Mandatory workspaces should exist
TS_ASSERT_EQUALS(ADS.doesExist("IvsQ_1234"), true);
TS_ASSERT_EQUALS(ADS.doesExist("IvsQ_binned_1234"), true);
// IvsLam is currently always output for group workspaces
TS_ASSERT_EQUALS(ADS.doesExist("IvsLam_1234"), true);
auto outQGroup = retrieveOutWS("IvsQ_1234");
auto outQGroupBinned = retrieveOutWS("IvsQ_binned_1234");
TS_ASSERT_EQUALS(outQGroup.size(), 4);
TS_ASSERT_EQUALS(outQGroupBinned.size(), 4);
ADS.clear();
}
void
test_input_workspace_group_with_default_output_workspaces_and_debug_on() {
ReflectometryReductionOneAuto2 alg;
setup_alg_on_input_workspace_group_with_run_number(alg);
alg.setProperty("Debug", true);
TS_ASSERT_THROWS_NOTHING(alg.execute());
// Mandatory workspaces should exist
TS_ASSERT_EQUALS(ADS.doesExist("IvsQ_1234"), true);
TS_ASSERT_EQUALS(ADS.doesExist("IvsQ_binned_1234"), true);
TS_ASSERT_EQUALS(ADS.doesExist("IvsLam_1234"), true);
auto outLamGroup = retrieveOutWS("IvsLam_1234");
TS_ASSERT_EQUALS(outLamGroup.size(), 4);
ADS.clear();
}
void test_input_workspace_group_with_named_output_workspaces() {
ReflectometryReductionOneAuto2 alg;
setup_alg_on_input_workspace_group_with_run_number(alg);
alg.setPropertyValue("OutputWorkspace", "testIvsQ");
alg.setPropertyValue("OutputWorkspaceBinned", "testIvsQ_binned");
alg.setPropertyValue("OutputWorkspaceWavelength", "testIvsLam");
TS_ASSERT_THROWS_NOTHING(alg.execute());
// Mandatory workspaces should exist
TS_ASSERT_EQUALS(ADS.doesExist("testIvsQ"), true);
TS_ASSERT_EQUALS(ADS.doesExist("testIvsQ_binned"), true);
// IvsLam is currently always output for group workspaces
TS_ASSERT_EQUALS(ADS.doesExist("testIvsLam"), true);
auto outQGroup = retrieveOutWS("testIvsQ");
auto outQGroupBinned = retrieveOutWS("testIvsQ_binned");
TS_ASSERT_EQUALS(outQGroup.size(), 4);
TS_ASSERT_EQUALS(outQGroupBinned.size(), 4);
ADS.clear();
}
void test_input_workspace_group_with_named_output_workspaces_and_debug_on() {
ReflectometryReductionOneAuto2 alg;
setup_alg_on_input_workspace_group_with_run_number(alg);
alg.setPropertyValue("OutputWorkspace", "testIvsQ");
alg.setPropertyValue("OutputWorkspaceBinned", "testIvsQ_binned");
alg.setPropertyValue("OutputWorkspaceWavelength", "testIvsLam");
alg.setProperty("Debug", true);
TS_ASSERT_THROWS_NOTHING(alg.execute());
// Mandatory workspaces should exist
TS_ASSERT_EQUALS(ADS.doesExist("testIvsQ"), true);
TS_ASSERT_EQUALS(ADS.doesExist("testIvsQ_binned"), true);
TS_ASSERT_EQUALS(ADS.doesExist("testIvsLam"), true);
auto outLamGroup = retrieveOutWS("testIvsLam");
TS_ASSERT_EQUALS(outLamGroup.size(), 4);
ADS.clear();
}
void test_one_transmissionrun() { void test_one_transmissionrun() {
const double startX = 1000; const double startX = 1000;
const int nBins = 3; const int nBins = 3;
...@@ -916,6 +995,7 @@ public: ...@@ -916,6 +995,7 @@ public:
alg.setPropertyValue("OutputWorkspaceBinned", "IvsQ_binned"); alg.setPropertyValue("OutputWorkspaceBinned", "IvsQ_binned");
alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam");
alg.setPropertyValue("FirstTransmissionRun", "transWSGroup"); alg.setPropertyValue("FirstTransmissionRun", "transWSGroup");
alg.setProperty("Debug", true);
TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT_THROWS_NOTHING(alg.execute());
auto outQGroup = retrieveOutWS("IvsQ"); auto outQGroup = retrieveOutWS("IvsQ");
...@@ -1055,6 +1135,7 @@ public: ...@@ -1055,6 +1135,7 @@ public:
alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam");
alg.setPropertyValue("FirstTransmissionRun", "transWSGroup"); alg.setPropertyValue("FirstTransmissionRun", "transWSGroup");
alg.setPropertyValue("SecondTransmissionRun", "transWSGroup2"); alg.setPropertyValue("SecondTransmissionRun", "transWSGroup2");
alg.setProperty("Debug", true);
TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT_THROWS_NOTHING(alg.execute());
auto outQGroup = retrieveOutWS("IvsQ"); auto outQGroup = retrieveOutWS("IvsQ");
...@@ -1563,6 +1644,25 @@ private: ...@@ -1563,6 +1644,25 @@ private:
flood->getAxis(0)->setUnit("TOF"); flood->getAxis(0)->setUnit("TOF");
return flood; return flood;
} }
void setup_alg_on_input_workspace_group_with_run_number(
ReflectometryReductionOneAuto2 &alg) {
std::string const name = "input";
prepareInputGroup(name);
WorkspaceGroup_sptr group = ADS.retrieveWS<WorkspaceGroup>("input");
MatrixWorkspace_sptr ws =
ADS.retrieveWS<MatrixWorkspace>(group->getNames()[0]);
ws->mutableRun().addProperty<std::string>("run_number", "1234");
alg.initialize();
alg.setChild(true);
alg.setPropertyValue("InputWorkspace", name);
alg.setProperty("WavelengthMin", 0.0000000001);
alg.setProperty("WavelengthMax", 15.0);
alg.setProperty("ThetaIn", 10.0);
alg.setProperty("ProcessingInstructions", "2");
alg.setProperty("MomentumTransferStep", 0.04);
}
}; };
#endif /* MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTO2TEST_H_ */ #endif /* MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTO2TEST_H_ */
...@@ -53,10 +53,9 @@ std::vector<MatrixWorkspace_sptr> retrieveOutWS(std::string const &name); ...@@ -53,10 +53,9 @@ std::vector<MatrixWorkspace_sptr> retrieveOutWS(std::string const &name);
// original. // original.
void applyPolarizationEfficiencies(std::string const &name); void applyPolarizationEfficiencies(std::string const &name);
MatrixWorkspace_sptr MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins,
createWorkspaceSingle(const double startX = 1, const int nBins = 3, const double deltaX,
const double deltaX = 1, const std::vector<double> &yValues);
const std::vector<double> &yValues = {1, 2, 3});
MatrixWorkspace_sptr createWorkspaceSingle(const double startX = 1, MatrixWorkspace_sptr createWorkspaceSingle(const double startX = 1,
const int nBins = 3, const int nBins = 3,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment