[3b7b218] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | from mock import MagicMock |
---|
| 4 | |
---|
| 5 | from PyQt4 import QtGui |
---|
| 6 | import matplotlib.pyplot as plt |
---|
| 7 | from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas |
---|
| 8 | from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar |
---|
| 9 | |
---|
| 10 | ####### TEMP |
---|
| 11 | import path_prepare |
---|
| 12 | ####### |
---|
| 13 | |
---|
| 14 | from sas.qtgui.ScaleProperties import ScaleProperties |
---|
| 15 | #import sas.qtgui.GuiUtils as GuiUtils |
---|
| 16 | from sas.qtgui.GuiUtils import * |
---|
| 17 | |
---|
| 18 | # Tested module |
---|
| 19 | import sas.qtgui.PlotterBase as PlotterBase |
---|
| 20 | |
---|
| 21 | app = QtGui.QApplication(sys.argv) |
---|
| 22 | |
---|
| 23 | class PlotterBaseTest(unittest.TestCase): |
---|
| 24 | '''Test the Plotter base class''' |
---|
| 25 | def setUp(self): |
---|
| 26 | '''create''' |
---|
| 27 | class dummy_manager(object): |
---|
| 28 | def communicator(self): |
---|
| 29 | return Communicate() |
---|
| 30 | def perspective(self): |
---|
| 31 | return MyPerspective() |
---|
| 32 | |
---|
| 33 | #PlotterBase.PlotterBase.updatePlotHelper = MagicMock() |
---|
| 34 | #self.plotter = PlotterBase.PlotterBase(None, manager=dummy_manager()) |
---|
| 35 | |
---|
| 36 | PlotterBase.PlotterBase.contextMenuQuickPlot = MagicMock() |
---|
| 37 | self.plotter = PlotterBase.PlotterBase(None, manager=dummy_manager(), quickplot=True) |
---|
| 38 | |
---|
| 39 | def tearDown(self): |
---|
| 40 | '''destroy''' |
---|
| 41 | self.plotter = None |
---|
| 42 | self.plotter_qp = None |
---|
| 43 | |
---|
| 44 | def testDefaults(self): |
---|
| 45 | """ default method variables values """ |
---|
| 46 | self.assertIsInstance(self.plotter, QtGui.QWidget) |
---|
| 47 | self.assertIsInstance(self.plotter.canvas, FigureCanvas) |
---|
| 48 | self.assertIsInstance(self.plotter.toolbar, NavigationToolbar) |
---|
| 49 | self.assertIsInstance(self.plotter.properties, ScaleProperties) |
---|
| 50 | |
---|
| 51 | self.assertEqual(self.plotter._data, []) |
---|
| 52 | self.assertEqual(self.plotter._xscale, 'log') |
---|
| 53 | self.assertEqual(self.plotter._yscale, 'log') |
---|
| 54 | self.assertEqual(self.plotter.scale, 'linear') |
---|
| 55 | self.assertFalse(self.plotter.grid_on) |
---|
| 56 | self.assertEqual(self.plotter.x_label, 'log10(x)') |
---|
| 57 | self.assertEqual(self.plotter.y_label, 'log10(y)') |
---|
| 58 | |
---|
| 59 | def testData(self): |
---|
| 60 | ''' Test the pure virtual method ''' |
---|
| 61 | with self.assertRaises(NotImplementedError): |
---|
| 62 | self.plotter.data=[] |
---|
| 63 | |
---|
| 64 | def testContextMenu(self): |
---|
| 65 | ''' Test the default context menu ''' |
---|
| 66 | pass |
---|
| 67 | |
---|
| 68 | def testContextMenuQuickPlot(self): |
---|
| 69 | ''' Test the default quick context menu ''' |
---|
| 70 | pass |
---|
| 71 | |
---|
| 72 | def testClean(self): |
---|
| 73 | ''' test the graph cleanup ''' |
---|
| 74 | pass |
---|
| 75 | |
---|
| 76 | def testPlot(self): |
---|
| 77 | ''' test the pure virtual method ''' |
---|
| 78 | with self.assertRaises(NotImplementedError): |
---|
| 79 | self.plotter.plot() |
---|
| 80 | |
---|
| 81 | def testOnCloseEvent(self): |
---|
| 82 | ''' test the plotter close behaviour ''' |
---|
| 83 | pass |
---|
| 84 | |
---|
| 85 | def testOnImageSave(self): |
---|
| 86 | ''' test the workspace save ''' |
---|
| 87 | pass |
---|
| 88 | |
---|
| 89 | def testOnImagePrint(self): |
---|
| 90 | ''' test the workspace print ''' |
---|
| 91 | pass |
---|
| 92 | |
---|
| 93 | def tesOonClipboardCopy(self): |
---|
| 94 | ''' test the workspace copy ''' |
---|
| 95 | pass |
---|
| 96 | |
---|
| 97 | def testOnGridToggle(self): |
---|
| 98 | ''' test toggling the grid lines ''' |
---|
| 99 | pass |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | if __name__ == "__main__": |
---|
| 103 | unittest.main() |
---|