Ignore:
Timestamp:
May 10, 2017 9:36:13 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
1bc27f1
Parents:
2da5759
Message:

Further fitpage implementation with tests SASVIEW-570

File:
1 edited

Legend:

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

    r2add354 r672b8ab  
    301301        self.widget.calculateResiduals(test_data) 
    302302        # Now, the difference is non-zero 
    303         self.assertEqual(float(self.widget.lblChi2Value.text()), 1.715) 
     303        self.assertEqual(float(self.widget.lblChi2Value.text()), 1.7151) 
    304304 
    305305    def testSetPolyModel(self): 
     
    550550            self.assertEqual(update_spy.count(), 1) 
    551551 
     552    def testReadFitPage(self): 
     553        """ 
     554        Read in the fitpage object and restore state 
     555        """ 
     556        # Set data 
     557        test_data = Data1D(x=[1,2], y=[1,2]) 
     558 
     559        # Force same data into logic 
     560        self.widget.logic.data = test_data 
     561        self.widget.data_is_loaded = True 
     562        category_index = self.widget.cbCategory.findText('Sphere') 
     563        self.widget.cbCategory.setCurrentIndex(category_index) 
     564        self.widget.parameters_to_fit = ['scale'] 
     565        # Invoke the tested method 
     566        fp = self.widget.currentState() 
     567 
     568        # Prepare modified fit page 
     569        fp.current_model = 'onion' 
     570        fp.is_polydisperse = True 
     571 
     572        # Read in modified state 
     573        self.widget.readFitPage(fp) 
     574 
     575        # Check if the widget got updated accordingly 
     576        self.assertEqual(self.widget.cbModel.currentText(), 'onion') 
     577        self.assertTrue(self.widget.chkPolydispersity.isChecked()) 
     578 
     579    def testCurrentState(self): 
     580        """ 
     581        Set up the fitpage with current state 
     582        """ 
     583        # Set data 
     584        test_data = Data1D(x=[1,2], y=[1,2]) 
     585 
     586        # Force same data into logic 
     587        self.widget.logic.data = test_data 
     588        self.widget.data_is_loaded = True 
     589        category_index = self.widget.cbCategory.findText("Sphere") 
     590        self.widget.cbCategory.setCurrentIndex(category_index) 
     591        self.widget.parameters_to_fit = ['scale'] 
     592 
     593        # Invoke the tested method 
     594        fp = self.widget.currentState() 
     595 
     596        # Test some entries. (Full testing of fp is done in FitPageTest) 
     597        self.assertIsInstance(fp.data, Data1D) 
     598        self.assertListEqual(list(fp.data.x), [1,2]) 
     599        self.assertTrue(fp.data_is_loaded) 
     600        self.assertEqual(fp.current_category, "Sphere") 
     601        self.assertEqual(fp.current_model, "adsorbed_layer") 
     602        self.assertListEqual(fp.parameters_to_fit, ['scale']) 
     603 
     604    def testPushFitPage(self): 
     605        """ 
     606        Push current state of fitpage onto stack 
     607        """ 
     608        pass 
     609 
     610    def testPopFitPage(self): 
     611        """ 
     612        Pop current state of fitpage from stack 
     613        """ 
     614        pass 
    552615 
    553616if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.