Changeset a281ab8 in sasview for src/sas/qtgui/UnitTesting
- Timestamp:
- Jun 15, 2016 5:57:34 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:
- 1042dba
- Parents:
- 5032ea68
- Location:
- src/sas/qtgui/UnitTesting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/UnitTesting/DataExplorerTest.py
r5032ea68 ra281ab8 1 1 import sys 2 2 import unittest 3 #from twisted.trial import unittest4 #from twisted.internet import reactor, defer, interfaces, threads, protocol, error5 3 6 4 from PyQt4.QtGui import * … … 27 25 def allowBatch(self): 28 26 return False 29 def setData(self, data_ list=None):27 def setData(self, data_item=None): 30 28 return None 31 29 def title(self): … … 271 269 """ 272 270 271 message="Loading Data Complete" 273 272 data_dict = {"a1":Data1D()} 273 output_data = (data_dict, message) 274 274 275 275 self.form.manager.add_data = MagicMock() … … 280 280 281 281 # Read in the file 282 self.form.loadComplete( data_dict, message="Loading Data Complete")282 self.form.loadComplete(output_data) 283 283 284 284 # "Loading data complete" no longer sent in LoadFile but in callback -
src/sas/qtgui/UnitTesting/GuiUtilsTest.py
rf721030 ra281ab8 1 import sys 2 import unittest 3 4 # Tested module 5 from GuiUtils import * 6 7 class GuiUtilsTest(unittest.TestCase): 8 '''Test the GUI Utilities methods''' 9 def setUp(self): 10 '''Empty''' 11 pass 12 13 def tearDown(self): 14 '''empty''' 15 pass 16 17 def testDefaults(self): 18 """ 19 Test all the global constants defined in the file. 20 """ 21 # Should probably test the constants in the file, 22 # but this will done after trimming down GuiUtils 23 # and retaining only necessary variables. 24 pass 25 26 def testGetAppDir(self): 27 """ 28 """ 29 pass 30 31 def testGetUserDirectory(self): 32 """ 33 Simple test of user directory getter 34 """ 35 home_dir = os.path.expanduser("~") 36 self.assertIn(home_dir, get_user_directory()) 37 38 def testCommunicate(self): 39 """ 40 Test the container class with signal definitions 41 """ 42 com = Communicate() 43 44 # All defined signals 45 list_of_signals = [ 46 'fileReadSignal', 47 'fileDataReceivedSignal', 48 'statusBarUpdateSignal', 49 'updatePerspectiveWithDataSignal', 50 'updateModelFromPerspectiveSignal' 51 ] 52 53 # Assure all signals are defined. 54 for signal in list_of_signals: 55 self.assertIn(signal, dir(com)) 56 57 58 def testUpdateModelItem(self): 59 """ 60 Test the QModelItem update method 61 """ 62 test_item = QtGui.QStandardItem() 63 test_list = ['aa','11'] 64 update_data = QtCore.QVariant(test_list) 65 name = "Black Sabbath" 66 67 # update the item 68 updateModelItem(test_item, update_data, name) 69 70 # Make sure test_item got all data added 71 self.assertEqual(test_item.child(0).text(), name) 72 self.assertTrue(test_item.child(0).isCheckable()) 73 list_from_item = test_item.child(0).child(0).data().toPyObject() 74 self.assertIsInstance(list_from_item, list) 75 self.assertEqual(str(list_from_item[0]), test_list[0]) 76 self.assertEqual(str(list_from_item[1]), test_list[1]) 77 78 if __name__ == "__main__": 79 unittest.main() 80
Note: See TracChangeset
for help on using the changeset viewer.