Changeset 4f9226c in sasview


Ignore:
Timestamp:
Oct 24, 2017 9:25:02 AM (7 years ago)
Author:
wojciech
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:
867020f
Parents:
9867860
Message:

Added unit tests for enabling/disabling magnetism checkbox

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    rc7358b2 r4f9226c  
    2020from sas.qtgui.Plotting.PlotterData import Data2D 
    2121 
    22 if not QtGui.QApplication.instance(): 
    23     app = QtGui.QApplication(sys.argv) 
     22#if not QtGui.QApplication.instance(): 
     23app = QtGui.QApplication(sys.argv) 
    2424 
    2525class dummy_manager(object): 
     
    784784        self.assertEqual(self.widget.cbModel.currentText(), 'onion') 
    785785        self.assertTrue(self.widget.chkPolydispersity.isChecked()) 
     786        #Check if polidispersity tab is available 
     787        self.assertTrue(self.widget.tabFitting.isTabEnabled(3)) 
     788 
     789        #Check if magnetism box and tab are disabled when 1D data is loaded 
     790        self.assertFalse(self.widget.chkMagnetism.isEnabled()) 
     791        self.assertFalse(self.widget.tabFitting.isTabEnabled(4)) 
     792 
     793    def testReadFitPage2D(self): 
     794        """ 
     795        Read in the fitpage object and restore state 
     796        """ 
     797        # Set data 
     798 
     799        test_data = Data2D(image=[1.0, 2.0, 3.0], 
     800                           err_image=[0.01, 0.02, 0.03], 
     801                           qx_data=[0.1, 0.2, 0.3], 
     802                           qy_data=[0.1, 0.2, 0.3], 
     803                           xmin=0.1, xmax=0.3, ymin=0.1, ymax=0.3, 
     804                           mask=[True, True, True]) 
     805 
     806        # Force same data into logic 
     807        self.widget.logic.data = test_data 
     808        self.widget.data_is_loaded = True 
     809 
     810        #item = QtGui.QStandardItem() 
     811        #updateModelItem(item, [test_data], "test") 
     812        # Force same data into logic 
     813        #self.widget.logic.data = item 
     814        #self.widget.data_is_loaded = True 
     815 
     816        category_index = self.widget.cbCategory.findText("Cylinder") 
     817        self.widget.cbCategory.setCurrentIndex(category_index) 
     818 
     819        # Test no fitting params 
     820        self.widget.parameters_to_fit = ['scale'] 
     821 
     822        # Invoke the tested method 
     823        fp = self.widget.currentState() 
     824 
     825        # Prepare modified fit page 
     826        fp.current_model = 'cylinder' 
     827        fp.is_polydisperse = True 
     828        fp.is_magnetic = True 
     829        fp.is2D = True 
     830 
     831        # Read in modified state 
     832        self.widget.readFitPage(fp) 
     833 
     834        # Check if the widget got updated accordingly 
     835        self.assertEqual(self.widget.cbModel.currentText(), 'cylinder') 
     836        self.assertTrue(self.widget.chkPolydispersity.isChecked()) 
     837        self.assertTrue(self.widget.chkPolydispersity.isEnabled()) 
     838        #Check if polidispersity tab is available 
     839        self.assertTrue(self.widget.tabFitting.isTabEnabled(3)) 
     840 
     841        #Check if magnetism box and tab are disabled when 1D data is loaded 
     842        self.assertTrue(self.widget.chkMagnetism.isChecked()) 
     843        self.assertTrue(self.widget.chkMagnetism.isEnabled()) 
     844        self.assertTrue(self.widget.tabFitting.isTabEnabled(4)) 
    786845 
    787846    def testCurrentState(self): 
Note: See TracChangeset for help on using the changeset viewer.