source: sasview/src/sas/qtgui/UnitTesting/ScalePropertiesTest.py @ 454670d

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 454670d was 6d05e1d, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

More functionality for quick plots + unit tests

  • Property mode set to 100755
File size: 1.9 KB
Line 
1import sys
2import unittest
3
4from PyQt4 import QtGui
5
6# set up import paths
7import path_prepare
8
9# Local
10from ScaleProperties import ScaleProperties
11
12app = QtGui.QApplication(sys.argv)
13
14class ScalePropertiesTest(unittest.TestCase):
15    '''Test the ScaleProperties'''
16    def setUp(self):
17        '''Create the ScaleProperties'''
18
19        self.widget = ScaleProperties(None)
20
21    def tearDown(self):
22        '''Destroy the GUI'''
23        self.widget.close()
24        self.widget = None
25
26    def testDefaults(self):
27        '''Test the GUI in its default state'''
28        self.assertIsInstance(self.widget, QtGui.QDialog)
29        self.assertEqual(self.widget.windowTitle(), "Scale Properties")
30        self.assertEqual(self.widget.cbX.count(), 6)
31        self.assertEqual(self.widget.cbY.count(), 12)
32        self.assertEqual(self.widget.cbView.count(), 6)
33       
34    def testGetValues(self):
35        '''Test the values returned'''
36        self.assertEqual(self.widget.getValues(), ("x", "y"))
37        self.widget.cbX.setCurrentIndex(2)
38        self.widget.cbY.setCurrentIndex(4)
39        self.assertEqual(self.widget.getValues(), ("x^(4)", "y*x^(2)"))
40
41    def testSettingView(self):
42        '''Test various settings of view'''
43        self.widget.cbView.setCurrentIndex(1)
44        self.assertEqual(self.widget.getValues(), ("x", "y"))
45        self.widget.cbView.setCurrentIndex(5)
46        self.assertEqual(self.widget.getValues(), ("x", "y*x^(2)"))
47
48        # Assure the View combobox resets on the x index changes
49        self.assertNotEqual(self.widget.cbView.currentIndex(), 0)
50        self.widget.cbX.setCurrentIndex(2)
51        self.assertEqual(self.widget.cbView.currentIndex(), 0)
52
53        # Same for Y
54        self.widget.cbView.setCurrentIndex(6)
55        self.assertNotEqual(self.widget.cbView.currentIndex(), 0)
56        self.widget.cbY.setCurrentIndex(2)
57        self.assertEqual(self.widget.cbView.currentIndex(), 0)
58     
59if __name__ == "__main__":
60    unittest.main()
Note: See TracBrowser for help on using the repository browser.