Ignore:
Timestamp:
Sep 7, 2018 7:40:56 AM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
c0de493
Parents:
0109f2a (diff), dcabba7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Torin Cooper-Bennun <40573959+tcbennun@…> (09/07/18 07:40:56)
git-committer:
GitHub <noreply@…> (09/07/18 07:40:56)
Message:

Merge branch 'ESS_GUI' into ESS_GUI_iss966

File:
1 edited

Legend:

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

    r3fbd77b r4ea8020  
    1818from sas.qtgui.Perspectives.Fitting.FittingWidget import * 
    1919from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 
    20  
     20import sas.qtgui.Utilities.LocalConfig 
    2121from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy 
     22from sas.qtgui.Perspectives.Fitting.ModelThread import Calc1D 
     23from sas.qtgui.Perspectives.Fitting.ModelThread import Calc2D 
    2224 
    2325from sas.qtgui.Plotting.PlotterData import Data1D 
     
    260262        self.widget.cbModel.setCurrentIndex(0) 
    261263 
    262         # Observe factor reset to None 
    263         self.assertEqual(self.widget.cbStructureFactor.currentText(), STRUCTURE_DEFAULT) 
     264        # Observe factor doesn't reset to None 
     265        self.assertEqual(self.widget.cbStructureFactor.currentText(), 'squarewell') 
    264266 
    265267        # Switch category to structure factor 
     
    319321        Check that the fitting 1D data object is ready 
    320322        """ 
    321         # Mock the thread creation 
    322         threads.deferToThread = MagicMock() 
    323         # Model for theory 
    324         self.widget.SASModelToQModel("cylinder") 
    325         # Call the tested method 
    326         self.widget.calculateQGridForModel() 
    327         time.sleep(1) 
    328         # Test the mock 
    329         self.assertTrue(threads.deferToThread.called) 
    330         self.assertEqual(threads.deferToThread.call_args_list[0][0][0].__name__, "compute") 
     323 
     324        if LocalConfig.USING_TWISTED: 
     325            # Mock the thread creation 
     326            threads.deferToThread = MagicMock() 
     327            # Model for theory 
     328            self.widget.SASModelToQModel("cylinder") 
     329            # Call the tested method 
     330            self.widget.calculateQGridForModel() 
     331            time.sleep(1) 
     332            # Test the mock 
     333            self.assertTrue(threads.deferToThread.called) 
     334            self.assertEqual(threads.deferToThread.call_args_list[0][0][0].__name__, "compute") 
     335        else: 
     336            Calc2D.queue = MagicMock() 
     337            # Model for theory 
     338            self.widget.SASModelToQModel("cylinder") 
     339            # Call the tested method 
     340            self.widget.calculateQGridForModel() 
     341            time.sleep(1) 
     342            # Test the mock 
     343            self.assertTrue(Calc2D.queue.called) 
    331344 
    332345    def testCalculateResiduals(self): 
     
    417430        index = self.widget._poly_model.index(0,0) 
    418431 
    419         #self.widget.show() 
    420         #QtWidgets.QApplication(sys.argv).exec_() 
    421  
    422432        # Set the checbox 
    423433        self.widget._poly_model.item(0,0).setCheckState(2) 
     
    435445        self.assertEqual(self.widget.kernel_module.details['radius_bell'][1], 1.0) 
    436446 
     447        #self.widget.show() 
     448        #QtWidgets.QApplication.exec_() 
     449 
    437450        # Change the number of points 
    438         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 35) 
     451        self.assertEqual(self.widget.poly_params['radius_bell.npts'], 35) 
    439452        self.widget._poly_model.item(0,4).setText("22") 
    440         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 22) 
     453        self.assertEqual(self.widget.poly_params['radius_bell.npts'], 22) 
    441454        # try something stupid 
    442455        self.widget._poly_model.item(0,4).setText("butt") 
    443456        # see that this didn't annoy the control at all 
    444         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 22) 
     457        self.assertEqual(self.widget.poly_params['radius_bell.npts'], 22) 
    445458 
    446459        # Change the number of sigmas 
    447         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 3) 
     460        self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 3) 
    448461        self.widget._poly_model.item(0,5).setText("222") 
    449         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 222) 
     462        self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 222) 
    450463        # try something stupid again 
    451464        self.widget._poly_model.item(0,4).setText("beer") 
    452465        # no efect 
    453         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 222) 
     466        self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 222) 
    454467 
    455468    def testOnPolyComboIndexChange(self): 
     
    472485        self.widget.onPolyComboIndexChange('rectangle', 0) 
    473486        # check values 
    474         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 35) 
    475         self.assertAlmostEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 1.73205, 5) 
     487        self.assertEqual(self.widget.poly_params['radius_bell.npts'], 35) 
     488        self.assertAlmostEqual(self.widget.poly_params['radius_bell.nsigmas'], 1.73205, 5) 
    476489        # Change the index 
    477490        self.widget.onPolyComboIndexChange('lognormal', 0) 
    478491        # check values 
    479         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 80) 
    480         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 8) 
     492        self.assertEqual(self.widget.poly_params['radius_bell.npts'], 80) 
     493        self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 8) 
    481494        # Change the index 
    482495        self.widget.onPolyComboIndexChange('schulz', 0) 
    483496        # check values 
    484         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 80) 
    485         self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 8) 
     497        self.assertEqual(self.widget.poly_params['radius_bell.npts'], 80) 
     498        self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 8) 
    486499 
    487500        # mock up file load 
     
    651664        self.assertEqual(self.widget.cmdPlot.text(), 'Show Plot') 
    652665 
    653         self.widget.show() 
    654  
    655666        # Set data 
    656667        test_data = Data1D(x=[1,2], y=[1,2]) 
    657  
     668        item = QtGui.QStandardItem() 
     669        updateModelItem(item, test_data, "test") 
    658670        # Force same data into logic 
    659         self.widget.logic.data = test_data 
    660         self.widget.data_is_loaded = True 
     671        self.widget.data = item 
    661672 
    662673        # Change the category index so we have a model available 
     
    704715        self.widget.close() 
    705716 
     717    def testOnEmptyFit2(self): 
    706718        test_data = Data2D(image=[1.0, 2.0, 3.0], 
    707719                           err_image=[0.01, 0.02, 0.03], 
     
    714726        item = QtGui.QStandardItem() 
    715727        updateModelItem(item, test_data, "test") 
     728 
    716729        # Force same data into logic 
    717730        self.widget.data = item 
     
    731744        self.widget.close() 
    732745 
    733  
    734     def testOnFit1D(self): 
     746    def notestOnFit1D(self): 
    735747        """ 
    736748        Test the threaded fitting call 
     
    770782        self.widget.close() 
    771783 
    772     def testOnFit2D(self): 
     784    def notestOnFit2D(self): 
    773785        """ 
    774786        Test the threaded fitting call 
     
    865877        # Set data 
    866878        test_data = Data1D(x=[1,2], y=[1,2]) 
    867  
     879        item = QtGui.QStandardItem() 
     880        updateModelItem(item, test_data, "test") 
    868881        # Force same data into logic 
    869         self.widget.logic.data = test_data 
    870         self.widget.data_is_loaded = True 
     882        self.widget.data = item 
     883 
     884        # Force same data into logic 
    871885        category_index = self.widget.cbCategory.findText('Sphere') 
     886 
    872887        self.widget.cbCategory.setCurrentIndex(category_index) 
    873888        self.widget.main_params_to_fit = ['scale'] 
     
    951966        # Set data 
    952967        test_data = Data1D(x=[1,2], y=[1,2]) 
    953  
     968        item = QtGui.QStandardItem() 
     969        updateModelItem(item, test_data, "test") 
    954970        # Force same data into logic 
    955         self.widget.logic.data = test_data 
    956         self.widget.data_is_loaded = True 
     971        self.widget.data = item 
    957972        category_index = self.widget.cbCategory.findText("Sphere") 
    958973        self.widget.cbCategory.setCurrentIndex(category_index) 
     
    976991        # Set data 
    977992        test_data = Data1D(x=[1,2], y=[1,2]) 
    978  
     993        item = QtGui.QStandardItem() 
     994        updateModelItem(item, test_data, "test") 
    979995        # Force same data into logic 
    980         self.widget.logic.data = test_data 
    981         self.widget.data_is_loaded = True 
     996        self.widget.data = item 
    982997        category_index = self.widget.cbCategory.findText("Sphere") 
    983998 
Note: See TracChangeset for help on using the changeset viewer.