Changes in src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py [3e8dee3:53c771e] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r3e8dee3 r53c771e 104 104 self.assertEqual(delegate.editableParameters(), [1, 2, 3, 4, 5]) 105 105 self.assertEqual(delegate.poly_function, 6) 106 self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal) 107 108 def testSelectMagnetism(self): 109 """ 110 Test if models have been loaded properly 111 """ 112 fittingWindow = self.widget 113 114 self.assertIsInstance(fittingWindow.lstMagnetic.itemDelegate(), QtGui.QStyledItemDelegate) 115 #Test loading from json categories 116 fittingWindow.SASModelToQModel("cylinder") 117 mag_index = fittingWindow.lstMagnetic.model().index(0,0) 118 self.assertEqual(str(mag_index.data().toString()), "up:frac_i") 119 mag_index = fittingWindow.lstMagnetic.model().index(1,0) 120 self.assertEqual(str(mag_index.data().toString()), "up:frac_f") 121 mag_index = fittingWindow.lstMagnetic.model().index(2,0) 122 self.assertEqual(str(mag_index.data().toString()), "up:angle") 123 mag_index = fittingWindow.lstMagnetic.model().index(3,0) 124 self.assertEqual(str(mag_index.data().toString()), "M0:sld") 125 mag_index = fittingWindow.lstMagnetic.model().index(4,0) 126 self.assertEqual(str(mag_index.data().toString()), "mtheta:sld") 127 mag_index = fittingWindow.lstMagnetic.model().index(5,0) 128 self.assertEqual(str(mag_index.data().toString()), "mphi:sld") 129 mag_index = fittingWindow.lstMagnetic.model().index(6,0) 130 self.assertEqual(str(mag_index.data().toString()), "M0:sld_solvent") 131 mag_index = fittingWindow.lstMagnetic.model().index(7,0) 132 self.assertEqual(str(mag_index.data().toString()), "mtheta:sld_solvent") 133 mag_index = fittingWindow.lstMagnetic.model().index(8,0) 134 self.assertEqual(str(mag_index.data().toString()), "mphi:sld_solvent") 135 136 # test the delegate a bit 137 delegate = fittingWindow.lstMagnetic.itemDelegate() 138 self.assertEqual(delegate.editableParameters(), [1, 2, 3]) 106 139 self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal) 107 140 … … 827 860 self.assertEqual(self.widget.cbModel.currentText(), 'onion') 828 861 self.assertTrue(self.widget.chkPolydispersity.isChecked()) 862 #Check if polidispersity tab is available 863 self.assertTrue(self.widget.tabFitting.isTabEnabled(3)) 864 865 #Check if magnetism box and tab are disabled when 1D data is loaded 866 self.assertFalse(self.widget.chkMagnetism.isEnabled()) 867 self.assertFalse(self.widget.tabFitting.isTabEnabled(4)) 868 869 def testReadFitPage2D(self): 870 """ 871 Read in the fitpage object and restore state 872 """ 873 # Set data 874 875 test_data = Data2D(image=[1.0, 2.0, 3.0], 876 err_image=[0.01, 0.02, 0.03], 877 qx_data=[0.1, 0.2, 0.3], 878 qy_data=[0.1, 0.2, 0.3], 879 xmin=0.1, xmax=0.3, ymin=0.1, ymax=0.3, 880 mask=[True, True, True]) 881 882 # Force same data into logic 883 self.widget.logic.data = test_data 884 self.widget.data_is_loaded = True 885 886 #item = QtGui.QStandardItem() 887 #updateModelItem(item, [test_data], "test") 888 # Force same data into logic 889 #self.widget.logic.data = item 890 #self.widget.data_is_loaded = True 891 892 category_index = self.widget.cbCategory.findText("Cylinder") 893 self.widget.cbCategory.setCurrentIndex(category_index) 894 895 # Test no fitting params 896 self.widget.parameters_to_fit = ['scale'] 897 898 # Invoke the tested method 899 fp = self.widget.currentState() 900 901 # Prepare modified fit page 902 fp.current_model = 'cylinder' 903 fp.is_polydisperse = True 904 fp.is_magnetic = True 905 fp.is2D = True 906 907 # Read in modified state 908 self.widget.readFitPage(fp) 909 910 # Check if the widget got updated accordingly 911 self.assertEqual(self.widget.cbModel.currentText(), 'cylinder') 912 self.assertTrue(self.widget.chkPolydispersity.isChecked()) 913 self.assertTrue(self.widget.chkPolydispersity.isEnabled()) 914 #Check if polidispersity tab is available 915 self.assertTrue(self.widget.tabFitting.isTabEnabled(3)) 916 917 #Check if magnetism box and tab are disabled when 1D data is loaded 918 self.assertTrue(self.widget.chkMagnetism.isChecked()) 919 self.assertTrue(self.widget.chkMagnetism.isEnabled()) 920 self.assertTrue(self.widget.tabFitting.isTabEnabled(4)) 829 921 830 922 def testCurrentState(self):
Note: See TracChangeset
for help on using the changeset viewer.