source: sasview/src/sas/qtgui/Calculators/UnitTesting/KiessigCalculatorTest.py @ 358b39d

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 358b39d was 83eb5208, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

Putting files in more ordered fashion

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