Changeset 64f1e93 in sasview for src/sas/qtgui/UnitTesting/Plotter2DTest.py
- Timestamp:
- Dec 7, 2016 5:47:22 AM (8 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 416fa8f
- Parents:
- 55d89f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/UnitTesting/Plotter2DTest.py
r55d89f8 r64f1e93 6 6 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 7 7 from mock import MagicMock 8 from mpl_toolkits.mplot3d import Axes3D 8 9 9 10 ####### TEMP … … 54 55 self.plotter.data = self.data 55 56 self.plotter.show() 56 FigureCanvas.draw = MagicMock()57 FigureCanvas.draw_idle = MagicMock() 57 58 58 59 self.plotter.plot() 59 60 60 #self.assertTrue(FigureCanvas.draw.called) 61 self.assertTrue(FigureCanvas.draw_idle.called) 62 63 def testOnToggleScale(self): 64 """ Respond to the event by replotting """ 65 self.plotter.data = self.data 66 self.plotter.show() 67 FigureCanvas.draw_idle = MagicMock() 68 69 self.plotter.onToggleScale(None) 70 71 self.assertTrue(FigureCanvas.draw_idle.called) 61 72 62 73 def testContextMenuQuickPlot(self): … … 99 110 # Trigger Change Scale and make sure the method is called 100 111 self.assertEqual(actions[6].text(), "Toggle Linear/Log Scale") 112 FigureCanvas.draw_idle = MagicMock() 113 actions[6].trigger() 114 self.assertTrue(FigureCanvas.draw_idle.called) 115 116 def testShowNoPlot(self): 117 """ Test the plot rendering and generation """ 118 119 FigureCanvas.draw_idle = MagicMock() 101 120 FigureCanvas.draw = MagicMock() 102 actions[6].trigger() 103 #self.assertTrue(FigureCanvas.draw.called) 121 122 # Test early return on no data 123 self.plotter.showPlot(data=None, 124 qx_data=self.data.qx_data, 125 qy_data=self.data.qy_data, 126 xmin=self.data.xmin, 127 xmax=self.data.xmax, 128 ymin=self.data.ymin, ymax=self.data.ymax, 129 cmap=None, zmin=None, 130 zmax=None) 131 132 self.assertFalse(FigureCanvas.draw_idle.called) 133 self.assertFalse(FigureCanvas.draw.called) 134 135 def testShow3DPlot(self): 136 """ Test the 3Dplot rendering and generation """ 137 # Test 3D printout 138 FigureCanvas.draw = MagicMock() 139 Axes3D.plot_surface = MagicMock() 140 self.plotter.figure.colorbar = MagicMock() 141 142 self.plotter.dimension = 3 143 self.plotter.data = self.data 144 self.plotter.showPlot(data=self.plotter.data.data, 145 qx_data=self.data.qx_data, 146 qy_data=self.data.qy_data, 147 xmin=self.data.xmin, 148 xmax=self.data.xmax, 149 ymin=self.data.ymin, ymax=self.data.ymax, 150 cmap=None, zmin=None, 151 zmax=None) 152 self.assertTrue(Axes3D.plot_surface.called) 153 self.assertTrue(FigureCanvas.draw.called) 154 155 def testShow2DPlot(self): 156 """ Test the 2Dplot rendering and generation """ 157 # Test 2D printout 158 FigureCanvas.draw_idle = MagicMock() 159 self.plotter.figure.colorbar = MagicMock() 160 161 self.plotter.dimension = 2 162 self.plotter.data = self.data 163 self.plotter.showPlot(data=self.plotter.data.data, 164 qx_data=self.data.qx_data, 165 qy_data=self.data.qy_data, 166 xmin=self.data.xmin, 167 xmax=self.data.xmax, 168 ymin=self.data.ymin, ymax=self.data.ymax, 169 cmap=None, zmin=None, 170 zmax=None) 171 self.assertTrue(FigureCanvas.draw_idle.called) 104 172 105 173
Note: See TracChangeset
for help on using the changeset viewer.