Changeset 0e4d87c in sasview


Ignore:
Timestamp:
Aug 16, 2017 4:09:33 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:
457d961
Parents:
377ade1
Message:

Added unit test for data reset

File:
1 edited

Legend:

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

    r377ade1 r0e4d87c  
    5252        self.assertEqual(self.widget.tabName(), "FitPage2") 
    5353        self.assertEqual(self.widget.maxIndex, 2) 
     54        # Add an empty batch tab 
     55        self.widget.addFit(None, is_batch=True) 
     56        self.assertEqual(len(self.widget.tabs), 3) 
     57        self.assertEqual(self.widget.tabName(2), "BatchPage3") 
     58        self.assertEqual(self.widget.maxIndex, 3) 
     59 
     60    def testResetTab(self): 
     61        ''' Remove data from last tab''' 
     62        self.assertEqual(len(self.widget.tabs), 1) 
     63        self.assertEqual(self.widget.tabName(), "FitPage1") 
     64        self.assertEqual(self.widget.maxIndex, 1) 
     65 
     66        # Attempt to remove the last tab 
     67        self.widget.resetTab(0) 
     68 
     69        # see that the tab didn't disappear, just changed the name/id 
     70        self.assertEqual(len(self.widget.tabs), 1) 
     71        self.assertEqual(self.widget.tabName(), "FitPage2") 
     72        self.assertEqual(self.widget.maxIndex, 2) 
     73 
     74        # Now, add data 
     75        data = Data1D(x=[1,2], y=[1,2]) 
     76        GuiUtils.dataFromItem = MagicMock(return_value=data) 
     77        item = QtGui.QStandardItem("test") 
     78        self.widget.setData([item]) 
     79        # Assert data is on widget 
     80        self.assertEqual(len(self.widget.tabs[0].all_data), 1) 
     81        # Reset the tab 
     82        self.widget.resetTab(0) 
     83        # See that the tab contains data no more 
     84        self.assertEqual(len(self.widget.tabs[0].all_data), 0) 
    5485 
    5586    def testCloseTab(self): 
Note: See TracChangeset for help on using the changeset viewer.