[3bdbfcc] | 1 | import sys |
---|
| 2 | import unittest |
---|
[7fb471d] | 3 | from unittest.mock import MagicMock |
---|
[3bdbfcc] | 4 | |
---|
[53c771e] | 5 | from PyQt5 import QtGui,QtWidgets |
---|
| 6 | from PyQt5 import QtCore |
---|
[3bdbfcc] | 7 | |
---|
| 8 | # set up import paths |
---|
| 9 | import path_prepare |
---|
| 10 | |
---|
| 11 | # Local |
---|
[83eb5208] | 12 | from sas.qtgui.Plotting.BoxSum import BoxSum |
---|
[3bdbfcc] | 13 | |
---|
[53c771e] | 14 | if not QtWidgets.QApplication.instance(): |
---|
| 15 | app = QtWidgets.QApplication(sys.argv) |
---|
[3bdbfcc] | 16 | |
---|
| 17 | class BoxSumTest(unittest.TestCase): |
---|
| 18 | '''Test the BoxSum''' |
---|
| 19 | def setUp(self): |
---|
| 20 | '''Create the BoxSum''' |
---|
| 21 | # example model |
---|
| 22 | model = QtGui.QStandardItemModel() |
---|
| 23 | parameters = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] |
---|
| 24 | for index, parameter in enumerate(parameters): |
---|
[cee5c78] | 25 | model.setData(model.index(0, index),parameter) |
---|
[3bdbfcc] | 26 | self.widget = BoxSum(None, model=model) |
---|
| 27 | |
---|
| 28 | def tearDown(self): |
---|
| 29 | '''Destroy the GUI''' |
---|
| 30 | self.widget.close() |
---|
| 31 | self.widget = None |
---|
| 32 | |
---|
| 33 | def testDefaults(self): |
---|
| 34 | '''Test the GUI in its default state''' |
---|
[53c771e] | 35 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(0), QtWidgets.QLineEdit) |
---|
| 36 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(1), QtWidgets.QLineEdit) |
---|
| 37 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(2), QtWidgets.QLineEdit) |
---|
| 38 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(3), QtWidgets.QLineEdit) |
---|
| 39 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(4), QtWidgets.QLabel) |
---|
| 40 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(5), QtWidgets.QLabel) |
---|
| 41 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(6), QtWidgets.QLabel) |
---|
| 42 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(7), QtWidgets.QLabel) |
---|
| 43 | self.assertIsInstance(self.widget.mapper.mappedWidgetAt(8), QtWidgets.QLabel) |
---|
[3bdbfcc] | 44 | |
---|
| 45 | |
---|
| 46 | if __name__ == "__main__": |
---|
| 47 | unittest.main() |
---|