source: sasview/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py @ da9a0722

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since da9a0722 was da9a0722, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

unit test updates

  • Property mode set to 100755
File size: 2.8 KB
Line 
1import sys
2import unittest
3import numpy as np
4
5from unittest.mock import MagicMock
6
7from PyQt5 import QtGui, QtCore, QtWidgets
8from PyQt5 import QtWebKit
9
10# set up import paths
11import path_prepare
12
13import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary
14
15# Local
16from sas.qtgui.Perspectives.Fitting.ConstraintWidget import ConstraintWidget
17from sas.qtgui.Perspectives.Fitting.Constraints import Constraint
18
19if not QtWidgets.QApplication.instance():
20    app = QtWidgets.QApplication(sys.argv)
21
22class ConstraintWidgetTest(unittest.TestCase):
23    '''Test the ConstraintWidget dialog'''
24    def setUp(self):
25        '''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
32        self.widget = ConstraintWidget(parent=dummy_perspective())
33
34        # Example constraint object
35        self.constraint1 = Constraint(parent=None, param="test", value="7.0", min="0.0", max="inf", func="M1:sld")
36        self.constraint2 = Constraint(parent=None, param="poop", value="7.0", min="0.0", max="inf", func="7.0")
37
38    def tearDown(self):
39        '''Destroy the GUI'''
40        self.widget.close()
41        self.widget = None
42
43    def testDefaults(self):
44        '''Test the GUI in its default state'''
45        self.assertIsInstance(self.widget, QtWidgets.QWidget)
46        # Default title
47        self.assertEqual(self.widget.windowTitle(), "Constrained and Simultaneous Fit")
48        # Dicts
49        self.assertIsInstance(self.widget.available_constraints, dict)
50        self.assertIsInstance(self.widget.available_tabs, dict)
51        # TableWidgets
52        self.assertEqual(self.widget.tblTabList.columnCount(), 4)
53        self.assertEqual(self.widget.tblConstraints.columnCount(), 1)
54
55    def testLabels(self):
56        ''' various labels on the widget '''
57        # params related setup
58        pass
59
60    def testTooltip(self):
61        ''' test the tooltip'''
62        pass
63
64    def testIsTabImportable(self):
65        ''' tab checks for consistency '''
66        test_tab = QtCore.QObject()
67        test_tab.data = self.constraint1
68        ObjectLibrary.getObject = MagicMock(return_value=test_tab)
69
70        self.assertFalse(self.widget.isTabImportable(None))
71        self.assertTrue(self.widget.isTabImportable("FitTab333333"))
72        self.assertFalse(self.widget.isTabImportable("BatchTab"))
73        self.assertFalse(self.widget.isTabImportable("BatchTab"))
74
75        pass
76
77    def testUpdateFitLine(self):
78        ''' See if the fit table row can be updated '''
79        pass
80
81    def testUpdateFitList(self):
82        ''' see if the fit table can be updated '''
83        pass
84
85    def testUpdateConstraintList(self):
86        ''' see if the constraint table can be updated '''
87        pass
88
89
Note: See TracBrowser for help on using the repository browser.