Changeset db5cd8d in sasview
- Timestamp:
- Jan 12, 2017 4:09:23 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:
- 2e3e959
- Parents:
- 87cc73a
- Location:
- src/sas/qtgui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/PlotProperties.py
r87cc73a rdb5cd8d 27 27 28 28 # Fill out the color combobox 29 self.cbColor.addItems(COLORS.keys() )29 self.cbColor.addItems(COLORS.keys()[:-1]) 30 30 # data1d.custom_color can now be a simple integer, 31 31 # specifying COLORS dict index or a string containing -
src/sas/qtgui/UnitTesting/PlotPropertiesTest.py
r87cc73a rdb5cd8d 1 1 import sys 2 2 import unittest 3 from mock import MagicMock 3 4 4 5 from PyQt4 import QtGui … … 6 7 # set up import paths 7 8 import path_prepare 8 9 from UnitTesting.TestUtils import WarningNotImplemented10 9 11 10 # Local … … 19 18 '''Create the PlotProperties''' 20 19 21 self.widget = PlotProperties(None) 20 self.widget = PlotProperties(None, 21 color=1, 22 marker=3, 23 marker_size=10, 24 legend="LL") 22 25 23 26 def tearDown(self): … … 30 33 self.assertIsInstance(self.widget, QtGui.QDialog) 31 34 self.assertEqual(self.widget.windowTitle(), "Modify Plot Properties") 35 36 # Check the combo boxes 37 self.assertEqual(self.widget.cbColor.currentText(), "Green") 38 self.assertEqual(self.widget.cbShape.currentText(), "Triangle Down") 39 self.assertEqual(self.widget.txtLegend.text(), "LL") 40 self.assertEqual(self.widget.sbSize.value(), 10) 32 41 33 42 def testOnColorChange(self): 34 43 '''Test the response to color change event''' 35 WarningNotImplemented(sys._getframe().f_code.co_name) 44 # Accept the new color 45 QtGui.QColorDialog.getColor = MagicMock(return_value=QtGui.QColor(255, 0, 255)) 46 47 self.widget.onColorChange(None) 48 49 self.assertEqual(self.widget.color(), "#ff00ff") 50 self.assertTrue(self.widget.custom_color) 51 self.assertEqual(self.widget.cbColor.currentIndex(), 7) 52 self.assertEqual(self.widget.cbColor.currentText(), "Custom") 53 54 # Reset the color - this will remove "Custom" from the combobox 55 # and set its index to "Green" 56 self.widget.cbColor.setCurrentIndex(1) 57 self.assertEqual(self.widget.cbColor.currentText(), "Green") 58 59 # Cancel the dialog now 60 bad_color = QtGui.QColor() # constructs an invalid color 61 QtGui.QColorDialog.getColor = MagicMock(return_value=bad_color) 62 self.widget.onColorChange(None) 63 64 self.assertEqual(self.widget.color(), 1) 65 self.assertFalse(self.widget.custom_color) 66 self.assertEqual(self.widget.cbColor.currentIndex(), 1) 67 self.assertEqual(self.widget.cbColor.currentText(), "Green") 68 36 69 37 70 def testOnColorIndexChange(self): 38 71 '''Test the response to color index change event''' 39 WarningNotImplemented(sys._getframe().f_code.co_name) 40 72 # Intitial population of the color combo box 73 self.widget.onColorIndexChange(0) 74 self.assertEqual(self.widget.cbColor.count(), 7) 75 # Block the callback so we can update the cb 76 self.widget.cbColor.blockSignals(True) 77 # Add the Custom entry 78 self.widget.cbColor.addItems(["Custom"]) 79 # Unblock the callback 80 self.widget.cbColor.blockSignals(False) 81 # Assert the new CB 82 self.assertEqual(self.widget.cbColor.count(), 8) 83 # Call the method 84 self.widget.onColorIndexChange(0) 85 # see that the Custom entry disappeared 86 self.assertEqual(self.widget.cbColor.count(), 7) 87 self.assertEqual(self.widget.cbColor.findText("Custom"), -1) 41 88 42 89 if __name__ == "__main__": -
src/sas/qtgui/UnitTesting/PlotUtilitiesTest.py
r87cc73a rdb5cd8d 3 3 from collections import OrderedDict 4 4 5 from UnitTesting.TestUtils import Warning NotImplemented5 from UnitTesting.TestUtils import WarningTestNotImplemented 6 6 7 7 # Tested module … … 25 25 def testBuildMatrix(self): 26 26 """ build matrix for 2d plot from a vector """ 27 Warning NotImplemented(sys._getframe().f_code.co_name)27 WarningTestNotImplemented() 28 28 29 29 def testGetBins(self): 30 30 """ test 1d arrays of the index with square binning """ 31 Warning NotImplemented(sys._getframe().f_code.co_name)31 WarningTestNotImplemented() 32 32 33 33 def testFillupPixels(self): 34 34 """ test filling z values of the empty cells of 2d image matrix """ 35 Warning NotImplemented(sys._getframe().f_code.co_name)35 WarningTestNotImplemented() 36 36 37 37 def testRescale(sef): 38 38 """ test the helper function for step based zooming """ 39 Warning NotImplemented(sys._getframe().f_code.co_name)39 WarningTestNotImplemented() 40 40 41 41 def testGgetValidColor(self): 42 42 """ test that the method returns a color understood by MPL """ 43 Warning NotImplemented(sys._getframe().f_code.co_name)43 WarningTestNotImplemented() 44 44 45 45 if __name__ == "__main__": -
src/sas/qtgui/UnitTesting/PlotterTest.py
r87cc73a rdb5cd8d 13 13 from sas.sasgui.guiframe.dataFitting import Data1D 14 14 from sas.sasgui.guiframe.dataFitting import Data2D 15 from UnitTesting.TestUtils import Warning NotImplemented15 from UnitTesting.TestUtils import WarningTestNotImplemented 16 16 17 17 # Tested module … … 224 224 def testOnLinearFit(self): 225 225 """ Checks the response to LinearFit call """ 226 Warning NotImplemented(sys._getframe().f_code.co_name)226 WarningTestNotImplemented() 227 227 228 228 def testOnRemovePlot(self): 229 229 """ Assure plots get removed when requested """ 230 Warning NotImplemented(sys._getframe().f_code.co_name)230 WarningTestNotImplemented() 231 231 232 232 def testRemovePlot(self): 233 233 """ Test plot removal """ 234 Warning NotImplemented(sys._getframe().f_code.co_name)234 WarningTestNotImplemented() 235 235 236 236 def testOnToggleHideError(self): 237 237 """ Test the error bar toggle on plots """ 238 Warning NotImplemented(sys._getframe().f_code.co_name)238 WarningTestNotImplemented() 239 239 240 240 def testOnFitDisplay(self): 241 241 """ Test the fit line display on the chart """ 242 Warning NotImplemented(sys._getframe().f_code.co_name)242 WarningTestNotImplemented() 243 243 244 244 def testReplacePlot(self): 245 245 """ Test the plot refresh functionality """ 246 Warning NotImplemented(sys._getframe().f_code.co_name)246 WarningTestNotImplemented() 247 247 248 248 def testReplacePlot(self): 249 249 """ Test the plot refresh functionality """ 250 Warning NotImplemented(sys._getframe().f_code.co_name)250 WarningTestNotImplemented(sys._getframe().f_code.co_name) 251 251 252 252 def testOnModifyPlot(self): 253 253 """ Test the functionality for changing plot properties """ 254 Warning NotImplemented(sys._getframe().f_code.co_name)254 WarningTestNotImplemented() 255 255 256 256 if __name__ == "__main__": -
src/sas/qtgui/UnitTesting/TestUtils.py
r87cc73a rdb5cd8d 2 2 from PyQt4.QtGui import * 3 3 from PyQt4.QtTest import * 4 import inspect 4 5 5 def WarningNotImplemented(method_name): 6 """ Prints warning about a non-implemented test """ 7 print("\nWARNING: %s needs implementing!"%method_name) 6 def WarningTestNotImplemented(method_name=None): 7 """ 8 Prints warning about a non-implemented test. 9 Test name retrieved from stack trace. 10 """ 11 if method_name is not None: 12 print("\nWARNING: %s needs implementing!"%method_name) 13 else: 14 (frame, filename, line_number, 15 function_name, lines, index) = inspect.getouterframes(inspect.currentframe())[1] 16 print("\nWARNING: %s needs implementing!"%function_name) 8 17 9 18 class QtSignalSpy(QObject):
Note: See TracChangeset
for help on using the changeset viewer.