Changeset a90c9c5 in sasview


Ignore:
Timestamp:
Feb 5, 2018 5:33:02 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:
725d9c06
Parents:
14ec91c5
Message:

Minor corrections to GUI and unit tests

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
5 edited

Legend:

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

    r14ec91c5 ra90c9c5  
    9494 
    9595        # External signals 
    96         self.parent.tabsModifiedSignal.connect(self.onModifiedTabs) 
     96        self.parent.tabsModifiedSignal.connect(self.initializeFitList) 
    9797 
    9898    def updateSignalsFromTab(self, tab=None): 
     
    283283        self.current_cell = self.tblTabList.item(row, column).data(0) 
    284284 
    285     def onModifiedTabs(self): 
    286         """ 
    287         Respond to tabs being deleted by deleting involved constraints 
    288  
    289         This should probably be done in FittingWidget as it is the owner of 
    290         all the fitting data, but I want to keep the FW oblivious about 
    291         dependence on other FW tabs, so enforcing the constraint deletion here. 
    292         """ 
    293         # Get the list of all constraints from querying the table 
    294         #constraints = getConstraintsForModel() 
    295  
    296         # Get the current list of tabs 
    297         #tabs = ObjectLibrary.listObjects() 
    298  
    299         # Check if any of the constraint dependencies got deleted 
    300         # Check the list of constraints 
    301         self.initializeFitList() 
    302         pass 
    303  
    304285    def onFitComplete(self, result): 
    305286        """ 
     
    677658        # Update the tab 
    678659        constrained_tab.addConstraintToRow(constraint, constrained_row) 
    679         pass 
  • src/sas/qtgui/Perspectives/Fitting/UI/ComplexConstraintUI.ui

    r14ec91c5 ra90c9c5  
    166166       </property> 
    167167       <property name="default"> 
    168         <bool>true</bool> 
     168        <bool>false</bool> 
    169169       </property> 
    170170      </widget> 
  • src/sas/qtgui/Perspectives/Fitting/UI/MultiConstraintUI.ui

    r14ec91c5 ra90c9c5  
    152152       </property> 
    153153       <property name="default"> 
    154         <bool>true</bool> 
     154        <bool>false</bool> 
    155155       </property> 
    156156      </widget> 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py

    rda9a0722 ra90c9c5  
    1818from sas.qtgui.Perspectives.Fitting.ComplexConstraint import ComplexConstraint 
    1919 
    20 #if not QtWidgets.QApplication.instance(): 
    21 #    app = QtWidgets.QApplication(sys.argv) 
    22 app = QtWidgets.QApplication(sys.argv) 
     20if not QtWidgets.QApplication.instance(): 
     21    app = QtWidgets.QApplication(sys.argv) 
    2322 
    2423class dummy_manager(object): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py

    r14ec91c5 ra90c9c5  
    77from PyQt5 import QtGui, QtCore, QtWidgets 
    88from PyQt5 import QtWebKit 
     9from PyQt5.QtTest import QTest 
    910 
    1011# set up import paths 
     
    1213 
    1314import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 
     15import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     16from sas.qtgui.Plotting.PlotterData import Data1D 
    1417 
    1518# Local 
    1619from sas.qtgui.Perspectives.Fitting.ConstraintWidget import ConstraintWidget 
    1720from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 
     21from sas.qtgui.Perspectives.Fitting.FittingPerspective import FittingWindow 
    1822 
    1923if not QtWidgets.QApplication.instance(): 
    2024    app = QtWidgets.QApplication(sys.argv) 
     25#app = QtWidgets.QApplication(sys.argv) 
    2126 
    2227class ConstraintWidgetTest(unittest.TestCase): 
     
    2429    def setUp(self): 
    2530        '''Create ConstraintWidget dialog''' 
    26         class dummy_perspective(QtWidgets.QTabWidget): 
    27             tabsModifiedSignal = QtCore.pyqtSignal() 
    28             def __init__(self): 
    29                 super(dummy_perspective, self).__init__() 
    30                 pass 
     31        class dummy_manager(object): 
     32            def communicator(self): 
     33                return GuiUtils.Communicate() 
     34            def communicate(self): 
     35                return GuiUtils.Communicate() 
    3136 
    32         self.widget = ConstraintWidget(parent=dummy_perspective()) 
     37        '''Create the perspective''' 
     38        self.perspective = FittingWindow(dummy_manager()) 
     39 
     40        self.widget = ConstraintWidget(parent=self.perspective) 
    3341 
    3442        # Example constraint object 
     
    5260        self.assertEqual(self.widget.tblTabList.columnCount(), 4) 
    5361        self.assertEqual(self.widget.tblConstraints.columnCount(), 1) 
     62        # Data accept  
     63        self.assertFalse(self.widget.acceptsData()) 
     64        # By default, the constraint table is disabled 
     65        self.assertFalse(self.widget.tblConstraints.isEnabled()) 
    5466 
    55     def testLabels(self): 
    56         ''' various labels on the widget ''' 
    57         # params related setup 
    58         pass 
     67    def testOnFitTypeChange(self): 
     68        ''' test the single/batch fit switch ''' 
     69        self.widget.initializeFitList = MagicMock() 
     70        # Assure current type is Single 
     71        self.assertEqual(self.widget.currentType, "FitPage") 
     72        # click on "batch" 
     73        QTest.mouseClick(self.widget.btnBatch, QtCore.Qt.LeftButton) 
     74        app.processEvents() 
     75        # See what the current type is now 
     76        self.assertEqual(self.widget.currentType, "BatchPage") 
     77        # See if the list is getting initialized 
     78        self.assertTrue(self.widget.initializeFitList.called) 
     79        # Go back to single fit 
     80        QTest.mouseClick(self.widget.btnSingle, QtCore.Qt.LeftButton) 
     81        app.processEvents() 
     82        # See what the current type is now 
     83        self.assertEqual(self.widget.currentType, "FitPage") 
    5984 
    60     def testTooltip(self): 
    61         ''' test the tooltip''' 
     85    def testGetTabsForFit(self): 
     86        ''' Test the fitting tab list ''' 
     87        self.assertEqual(self.widget.getTabsForFit(),[]) 
     88        # Add some tabs 
    6289        pass 
    6390 
     
    6996 
    7097        self.assertFalse(self.widget.isTabImportable(None)) 
    71         self.assertTrue(self.widget.isTabImportable("FitTab333333")) 
    72         self.assertFalse(self.widget.isTabImportable("BatchTab")) 
     98        self.assertFalse(self.widget.isTabImportable("BatchTab1")) 
    7399        self.assertFalse(self.widget.isTabImportable("BatchTab")) 
    74100 
    75         pass 
     101    def testOnTabCellEdit(self): 
     102        ''' test what happens on monicker edit ''' 
     103        # Mock the datafromitem() call from FittingWidget 
     104        data = Data1D(x=[1,2], y=[1,2]) 
     105        GuiUtils.dataFromItem = MagicMock(return_value=data) 
     106        item = QtGui.QStandardItem("test") 
     107        self.perspective.addFit([item]) 
    76108 
    77109    def testUpdateFitLine(self): 
Note: See TracChangeset for help on using the changeset viewer.