diff --git a/MantidPlot/CMakeLists.txt b/MantidPlot/CMakeLists.txt index acd3dde5f9f1924d0f5a97449c3a09e6fffc3d08..fe82ef4e93beaa3e36543bcc177107c76855df44 100644 --- a/MantidPlot/CMakeLists.txt +++ b/MantidPlot/CMakeLists.txt @@ -863,6 +863,7 @@ set ( MANTIDPLOT_TEST_PY_FILES MantidPlotSliceViewerTest.py MantidPlot1DPlotTest.py MantidPlot2DPlotTest.py + MantidPlotProjectSerialiseTest.py MantidPlotProxiesTest.py MantidPlotPythonImportTest.py MantidPlotFoldersTest.py diff --git a/MantidPlot/src/qti.sip b/MantidPlot/src/qti.sip index e7b4ecb286537437c6a14cef82f089fac60fe083..47ea6e03359518b2396e98c7b64ef63450035c89 100644 --- a/MantidPlot/src/qti.sip +++ b/MantidPlot/src/qti.sip @@ -1232,6 +1232,8 @@ public: void disableTools(); void saveProjectAs(const QString& fileName = QString(), bool = false); + void openProject(const QString& fileName = QString(), const int fileVersion = 0); + MdiSubWindow* clone(MdiSubWindow*); Matrix* tableToMatrix(Table* t); diff --git a/MantidPlot/test/MantidPlotProjectSerialiseTest.py b/MantidPlot/test/MantidPlotProjectSerialiseTest.py new file mode 100644 index 0000000000000000000000000000000000000000..c14e240adb831ce6ba1df26aa632b1b8eb985262 --- /dev/null +++ b/MantidPlot/test/MantidPlotProjectSerialiseTest.py @@ -0,0 +1,66 @@ +""" +Test of basic project saving and loading +""" +import mantidplottests +from mantidplottests import * +import numpy as np +from PyQt4 import QtGui, QtCore + + +class MantidPlotProjectSerialiseTest(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_saveProjectAs(self): + raise RuntimeError("FAIL") + + def test_openProject(self): + raise RuntimeError("FAIL") + + +def create_dummy_workspace(ws_name): + """ Create a dummy mantid workspace with some data """ + X1 = np.linspace(0,10, 100) + Y1 = 1000*(np.sin(X1)**2) + X1*10 + X1 = np.append(X1, 10.1) + + X2 = np.linspace(2,12, 100) + Y2 = 500*(np.cos(X2/2.)**2) + 20 + X2 = np.append(X2, 12.10) + + X = np.append(X1, X2) + Y = np.append(Y1, Y2) + E = np.sqrt(Y) + + CreateWorkspace(OutputWorkspace=ws_name, DataX=list(X), + DataY=list(Y), DataE=list(E), NSpec=2, + UnitX="TOF", YUnitLabel="Counts", + WorkspaceTitle="Faked data Workspace") + + +def read_project_file(folder_name): + """ Read lines from a .mantid project file """ + + if not os.path.isdir(folder_name): + raise IOError('Path is not a directory') + + project_name = os.path.basename(folder_name) + '.mantid' + project_file = os.path.join(project_name) + + if not os.path.isfile(project_file): + raise IOError('Project file could not be found') + + with open(project_file, 'r') as file_handle: + lines = file_handle.readlines() + + format_func = lambda s: s.strip().split('\t') + tokens = map(format_func, lines) + return tokens + + +# Run the unit tests +mantidplottests.runTests(MantidPlotProjectSerialiseTest)