Changeset b9c4c1e1 in sasview for src/sas/qtgui/Perspectives
- Timestamp:
- Feb 22, 2017 3:51:53 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:
- 84be77e
- Parents:
- 0efe791
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
r0efe791 rb9c4c1e1 17 17 Main window for selecting form and structure factor models 18 18 """ 19 name = "Fitting" # For displaying in the combo box20 19 def __init__(self, manager=None, parent=None): 21 20 """ … … 26 25 """ 27 26 super(FittingWindow, self).__init__() 28 27 self.setupUi(self) 28 29 self.setWindowTitle("Fitting") 29 30 self._model_model = QtGui.QStandardItemModel() 30 31 self._poly_model = QtGui.QStandardItemModel() 31 self.setupUi(self)32 32 self.tableView.setModel(self._model_model) 33 33 … … 53 53 self.chkSmearing.setEnabled(False) 54 54 55 #TODO: Can these be removed?56 55 self.lblMinRangeDef.setText("---") 57 56 self.lblMaxRangeDef.setText("---") -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py
r2162fa0 rb9c4c1e1 21 21 def tearDown(self): 22 22 """Destroy the GUI""" 23 self.widget.close() 23 24 self.widget = None 24 25 25 26 def testDefaults(self): 26 27 """Test the GUI in its default state""" 27 self.assertIsInstance(self.widget, QtGui.QMainWindow) 28 self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace) 28 self.assertIsInstance(self.widget, QtGui.QWidget) 29 self.assertEqual(self.widget.windowTitle(), "Fitting") 30 self.assertEqual(self.widget.sizePolicy().Policy(), QtGui.QSizePolicy.Fixed) 29 31 30 def test Exit(self):32 def testSelectCategory(self): 31 33 """ 32 Test that the custom exit method is called on shutdown 34 Test if categories have been load properly 35 :return: 33 36 """ 34 # Must mask sys.exit, otherwise the whole testing process stops. 35 sys.exit = MagicMock() 36 QtGui.QMessageBox.question = MagicMock(return_value=QtGui.QMessageBox.Yes) 37 fittingWindow = FittingWindow(None) 37 38 38 # Open, then close the main window 39 tmp_main = FittingWindow(None) 40 tmp_main.close() 39 #Test loading from json categories 40 category_list = fittingWindow.master_category_dict.keys() 41 self.assertTrue("Cylinder" in category_list) 42 self.assertTrue("Ellipsoid" in category_list) 43 self.assertTrue("Lamellae" in category_list) 44 self.assertTrue("Paracrystal" in category_list) 45 self.assertTrue("Parallelepiped" in category_list) 46 self.assertTrue("Shape Independent" in category_list) 47 self.assertTrue("Sphere" in category_list) 41 48 42 # See that the MessageBox method got called 43 self.assertTrue(QtGui.QMessageBox.question.called) 44 49 #Test for existence in combobox 50 self.assertNotEqual(fittingWindow.cbCategory.findText("Cylinder"),-1) 51 self.assertNotEqual(fittingWindow.cbCategory.findText("Ellipsoid"),-1) 52 self.assertNotEqual(fittingWindow.cbCategory.findText("Lamellae"),-1) 53 self.assertNotEqual(fittingWindow.cbCategory.findText("Paracrystal"),-1) 54 self.assertNotEqual(fittingWindow.cbCategory.findText("Parallelepiped"),-1) 55 self.assertNotEqual(fittingWindow.cbCategory.findText("Shape Independent"),-1) 56 self.assertNotEqual(fittingWindow.cbCategory.findText("Sphere"),-1) 57 58 #Test what is current text in the combobox 59 self.assertTrue(fittingWindow.cbCategory.currentText(), "Cylinder") 60 61 def testSelectModel(self): 62 """ 63 Test if models have been loaded properly 64 :return: 65 """ 66 fittingWindow = FittingWindow(None) 67 68 #Test loading from json categories 69 model_list = fittingWindow.master_category_dict["Cylinder"] 70 self.assertTrue(['cylinder', True] in model_list) 71 self.assertTrue(['core_shell_cylinder', True] in model_list) 72 self.assertTrue(['barbell', True] in model_list) 73 self.assertTrue(['core_shell_bicelle', True] in model_list) 74 self.assertTrue(['flexible_cylinder', True] in model_list) 75 self.assertTrue(['flexible_cylinder_elliptical', True] in model_list) 76 self.assertTrue(['pearl_necklace', True] in model_list) 77 self.assertTrue(['capped_cylinder', True] in model_list) 78 self.assertTrue(['elliptical_cylinder', True] in model_list) 79 self.assertTrue(['pringle', True] in model_list) 80 self.assertTrue(['hollow_cylinder', True] in model_list) 81 self.assertTrue(['core_shell_bicelle_elliptical', True] in model_list) 82 self.assertTrue(['stacked_disks', True] in model_list) 83 84 #Test for existence in combobox 85 self.assertNotEqual(fittingWindow.cbModel.findText("cylinder"),-1) 86 self.assertNotEqual(fittingWindow.cbModel.findText("core_shell_cylinder"),-1) 87 self.assertNotEqual(fittingWindow.cbModel.findText("barbell"),-1) 88 self.assertNotEqual(fittingWindow.cbModel.findText("core_shell_bicelle"),-1) 89 self.assertNotEqual(fittingWindow.cbModel.findText("flexible_cylinder"),-1) 90 self.assertNotEqual(fittingWindow.cbModel.findText("flexible_cylinder_elliptical"),-1) 91 self.assertNotEqual(fittingWindow.cbModel.findText("pearl_necklace"),-1) 92 self.assertNotEqual(fittingWindow.cbModel.findText("capped_cylinder"),-1) 93 self.assertNotEqual(fittingWindow.cbModel.findText("elliptical_cylinder"),-1) 94 self.assertNotEqual(fittingWindow.cbModel.findText("pringle"),-1) 95 self.assertNotEqual(fittingWindow.cbModel.findText("hollow_cylinder"),-1) 96 self.assertNotEqual(fittingWindow.cbModel.findText("core_shell_bicelle_elliptical"),-1) 97 self.assertNotEqual(fittingWindow.cbModel.findText("stacked_disks"),-1) 98 99 100 def testSelectStructureFactor(self): 101 """ 102 Test if structure factors have been loaded properly 103 :return: 104 """ 105 fittingWindow = FittingWindow(None) 106 107 #Test for existence in combobox 108 self.assertNotEqual(fittingWindow.cbStructureFactor.findText("stickyhardsphere"),-1) 109 self.assertNotEqual(fittingWindow.cbStructureFactor.findText("hayter_msa"),-1) 110 self.assertNotEqual(fittingWindow.cbStructureFactor.findText("squarewell"),-1) 111 self.assertNotEqual(fittingWindow.cbStructureFactor.findText("hardsphere"),-1) 112 113 #Test what is current text in the combobox 114 self.assertTrue(fittingWindow.cbCategory.currentText(), "None") 115 45 116 if __name__ == "__main__": 46 117 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.