-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #4316: A real live test for MantidPlot! WIP.
- Loading branch information
Janik Zikovsky
committed
Dec 22, 2011
1 parent
9640190
commit 2e2e44d
Showing
7 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" Test script for running python commands within MantidPlot. | ||
This will test the interface to SliceViewer widgets. | ||
Note: the SliceViewerPythonInterfaceTest.py offers | ||
more tests of specific functions. Might be merged together with | ||
this in the future? | ||
""" | ||
import sys | ||
import sys | ||
import os | ||
import unittest | ||
import time | ||
from PyQt4 import Qt | ||
|
||
|
||
CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='mdw') | ||
FakeMDEventData("mdw", UniformParams="1e5") | ||
FakeMDEventData("mdw", PeakParams="1e4, 2,4,6, 1.5") | ||
BinToMDHistoWorkspace("mdw", "uniform", 1, "x,0,10,30", "y,0,10,30", "z,0,10,30", IterateEvents="1", Parallel="0") | ||
|
||
class MantidPlotSliceViewerTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
closeAllSliceViewers() | ||
pass | ||
|
||
def test_plotSlice(self): | ||
""" Basic plotSlice() usage """ | ||
svw = plotSlice('uniform') | ||
self.assertEqual(svw.getSlicer().getWorkspaceName(), "uniform") | ||
|
||
def test_closingWindowIsSafe(self): | ||
svw = plotSlice('uniform', label='closing!') | ||
svw.close() | ||
|
||
def test_methods_pass_through(self): | ||
""" Methods called on SliceViewerWindow pass-through to the SliceViewer widget""" | ||
svw = plotSlice('uniform') | ||
svw.setSlicePoint(0, 2.5) | ||
self.assertAlmostEqual(svw.getSlicePoint(0), 2.5, 3) | ||
svw.setXYDim("z", "x") | ||
self.assertEqual(svw.getDimX(), 2) | ||
self.assertEqual(svw.getDimY(), 0) | ||
|
||
def test_plotSlice_arguments(self): | ||
""" Pass arguments to plotSlice """ | ||
svw = plotSlice('uniform', label='test_label', xydim=[1,2], | ||
slicepoint=[2.5, 0, 0], colormin=20, colormax=5000, colorscalelog=True, | ||
limits=[2, 8, 3, 9]) | ||
self.assertEqual(svw.getLabel(), "test_label") | ||
self.assertEqual(svw.getDimX(), 1) | ||
self.assertEqual(svw.getDimY(), 2) | ||
self.assertAlmostEqual(svw.getSlicePoint(0), 2.5, 3) | ||
self.assertAlmostEqual(svw.getColorScaleMin(), 20, 2) | ||
self.assertAlmostEqual(svw.getColorScaleMax(), 5000, 2) | ||
assert svw.getColorScaleLog() | ||
self.assertEqual(svw.getXLimits(), [2,8]) | ||
self.assertEqual(svw.getYLimits(), [3,9]) | ||
|
||
def test_plotSlice_arguments2(self): | ||
""" Another way to pass xydim """ | ||
svw = plotSlice('uniform', xydim=["y", "z"]) | ||
self.assertEqual(svw.getDimX(), 1) | ||
self.assertEqual(svw.getDimY(), 2) | ||
|
||
def test_getSliceViewer(self): | ||
""" Retrieving an open SliceViewer """ | ||
svw1 = plotSlice('uniform') | ||
svw2 = getSliceViewer('uniform') | ||
assert svw2 is not None | ||
self.assertEqual(svw2.getSlicer().getWorkspaceName(), "uniform") | ||
|
||
def test_getSliceViewer_failure(self): | ||
""" Retrieving an open SliceViewer, cases where it fails """ | ||
self.assertRaises(Exception, getSliceViewer, 'nonexistent') | ||
svw = plotSlice('uniform', label='alabel') | ||
self.assertRaises(Exception, getSliceViewer, 'uniform', 'different_label') | ||
|
||
|
||
# Custom code to create and run this single test suite | ||
suite = unittest.TestSuite() | ||
suite.addTest( unittest.makeSuite(MantidPlotSliceViewerTest) ) | ||
unittest.TextTestRunner().run(suite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Files generated by process_sip.sh | ||
mantidqt_dir.txt | ||
mantidqt_wiki.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters