source: sasview/src/sas/qtgui/Calculators/UnitTesting/KiessigCalculatorTest.py @ 53c771e

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 53c771e was 53c771e, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

Converted unit tests

  • Property mode set to 100644
File size: 2.7 KB
Line 
1import sys
2import unittest
3from PyQt5 import QtGui, QtWidgets
4from PyQt5.QtTest import QTest
5from PyQt5.QtCore import Qt
6
7# TEMP
8#import sas.qtgui.path_prepare
9import path_prepare
10
11
12from sas.qtgui.Calculators.KiessigPanel import KiessigPanel
13
14if not QtWidgets.QApplication.instance():
15    app = QtWidgets.QApplication(sys.argv)
16
17
18class KiessigCalculatorTest(unittest.TestCase):
19    """Test the KiessigCalculator"""
20    def setUp(self):
21        """Create the KiessigCalculator"""
22        self.widget = KiessigPanel(None)
23
24    def tearDown(self):
25        """Destroy the KiessigCalculator"""
26        self.widget.close()
27        self.widget = None
28
29    def testDefaults(self):
30        """Test the GUI in its default state"""
31        self.assertIsInstance(self.widget, QtWidgets.QWidget)
32        self.assertEqual(self.widget.windowTitle(), "Kiessig Thickness Calculator")
33        self.assertEqual(self.widget.sizePolicy().Policy(), QtWidgets.QSizePolicy.Fixed)
34
35    def testHelp(self):
36        """ Assure help file is shown """
37
38        # this should not rise
39        self.widget.onHelp()
40
41    def testComplexEntryNumbers(self):
42        """ User entered compound calculations and subsequent reset"""
43
44        self.widget.deltaq_in.clear()
45        self.widget.deltaq_in.insert('0.05')
46        #
47        # Push Compute with the left mouse button
48        computeButton = self.widget.computeButton
49        QTest.mouseClick(computeButton, Qt.LeftButton)
50        self.assertEqual(self.widget.lengthscale_out.text(), '125.664')
51
52    def testComplexEntryNumbers2(self):
53        """ User entered compound calculations and subsequent reset"""
54
55        self.widget.deltaq_in.clear()
56        self.widget.deltaq_in.insert('1.0')
57        #
58        # Push Compute with the left mouse button
59        computeButton = self.widget.computeButton
60        QTest.mouseClick(computeButton, Qt.LeftButton)
61        self.assertEqual(self.widget.lengthscale_out.text(), '6.283')
62
63    def testComplexEntryNumbers3(self):
64        """ User entered compound calculations and subsequent reset"""
65
66        self.widget.deltaq_in.clear()
67        self.widget.deltaq_in.insert('2.0')
68        #
69        # Push Compute with the left mouse button
70        computeButton = self.widget.computeButton
71        QTest.mouseClick(computeButton, Qt.LeftButton)
72        self.assertEqual(self.widget.lengthscale_out.text(), '3.142')
73
74    def testComplexEntryLetters(self):
75        """ User entered compound calculations and subsequent reset"""
76
77        self.widget.deltaq_in.insert("xyz")
78
79        # Push Compute with the left mouse button
80        computeButton = self.widget.computeButton
81        QTest.mouseClick(computeButton, Qt.LeftButton)
82        self.assertEqual(self.widget.lengthscale_out.text(), '')
83
84if __name__ == "__main__":
85    unittest.main()
Note: See TracBrowser for help on using the repository browser.