Skip to content
Snippets Groups Projects
Commit 5fdcfa20 authored by Matthew Andrew's avatar Matthew Andrew
Browse files

Updated MantidAxesTest.h Re #28194

This updates the test to check that the new return values of replaceWorkspaceArtists and removeWorkspaceArtists return correctly.
parent 8e01c54d
No related branches found
No related tags found
No related merge requests found
......@@ -56,8 +56,9 @@ public:
const std::string wsName{"myname"};
const auto ws = createWorkspaceInADS(wsName, {1, 2, 4});
axes.plot(ws, 0, "red", "mylabel");
axes.removeWorkspaceArtists(ws);
auto removed = axes.removeWorkspaceArtists(ws);
TS_ASSERT_EQUALS(removed, true);
TS_ASSERT_EQUALS(0, Python::Len(axes.pyobj().attr("lines")));
AnalysisDataService::Instance().remove(wsName);
}
......@@ -68,11 +69,43 @@ public:
const auto wsOld = createWorkspaceInADS(wsName, {1, 2, 4});
axes.plot(wsOld, 0, "red", "mylabel");
const auto wsNew = createWorkspaceInADS(wsName, {2, 3, 5});
axes.replaceWorkspaceArtists(wsNew);
auto replaces = axes.replaceWorkspaceArtists(wsNew);
auto newLine = axes.pyobj().attr("lines")[0];
TS_ASSERT_EQUALS(2.5, newLine.attr("get_xdata")()[0]);
TS_ASSERT_EQUALS("red", newLine.attr("get_color")());
TS_ASSERT_EQUALS(replaces, true);
AnalysisDataService::Instance().remove(wsName);
}
void testRemovingWorkspaceNotOnPlotReturnsFalse() {
MantidAxes axes{pyAxes()};
const std::string wsName{"myname"};
const std::string wsName2{"mynamenotPlotted"};
const auto ws = createWorkspaceInADS(wsName, {1, 2, 4});
const auto wsNotPlotted = createWorkspaceInADS(wsName2, {1, 2, 4});
axes.plot(ws, 0, "red", "mylabel");
auto removed = axes.removeWorkspaceArtists(wsNotPlotted);
TS_ASSERT_EQUALS(removed, false);
TS_ASSERT_EQUALS(1, Python::Len(axes.pyobj().attr("lines")));
AnalysisDataService::Instance().remove(wsName);
}
void testReplacingWorkspaceNotOnPlotReturnsFalse() {
MantidAxes axes{pyAxes()};
const std::string wsName{"myname"};
const std::string wsName2{"myname2"};
const auto wsOld = createWorkspaceInADS(wsName, {2, 3, 5});
axes.plot(wsOld, 0, "red", "mylabel");
const auto wsNew = createWorkspaceInADS(wsName2, {1, 2, 4});
auto replaces = axes.replaceWorkspaceArtists(wsNew);
auto newLine = axes.pyobj().attr("lines")[0];
TS_ASSERT_EQUALS(2.5, newLine.attr("get_xdata")()[0]);
TS_ASSERT_EQUALS("red", newLine.attr("get_color")());
TS_ASSERT_EQUALS(replaces, false);
AnalysisDataService::Instance().remove(wsName);
}
......
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