source: sasview/src/sas/qtgui/UnitTesting/PlotterBaseTest.py @ 3b7b218

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 3b7b218 was 3b7b218, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

Code review from TN + more unit tests for plotters

  • Property mode set to 100755
File size: 3.0 KB
Line 
1import sys
2import unittest
3from mock import MagicMock
4
5from PyQt4 import QtGui
6import matplotlib.pyplot as plt
7from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
8from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
9
10####### TEMP
11import path_prepare
12#######
13
14from sas.qtgui.ScaleProperties import ScaleProperties
15#import sas.qtgui.GuiUtils as GuiUtils
16from sas.qtgui.GuiUtils import *
17
18# Tested module
19import sas.qtgui.PlotterBase as PlotterBase
20
21app = QtGui.QApplication(sys.argv)
22
23class 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
102if __name__ == "__main__":
103    unittest.main()
Note: See TracBrowser for help on using the repository browser.