1 | import sys |
---|
2 | import unittest |
---|
3 | import numpy as np |
---|
4 | |
---|
5 | from unittest.mock import MagicMock |
---|
6 | |
---|
7 | from PyQt5 import QtGui, QtCore, QtWidgets |
---|
8 | from PyQt5 import QtWebKit |
---|
9 | |
---|
10 | # set up import paths |
---|
11 | import path_prepare |
---|
12 | |
---|
13 | import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary |
---|
14 | |
---|
15 | # Local |
---|
16 | from sas.qtgui.Perspectives.Fitting.ConstraintWidget import ConstraintWidget |
---|
17 | from sas.qtgui.Perspectives.Fitting.Constraints import Constraint |
---|
18 | |
---|
19 | if not QtWidgets.QApplication.instance(): |
---|
20 | app = QtWidgets.QApplication(sys.argv) |
---|
21 | |
---|
22 | class 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 | |
---|