source: sasview/src/sas/qtgui/Plotting/UnitTesting/ScalePropertiesTest.py @ b8080e1

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since b8080e1 was b8080e1, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

cherry picking sascalc changes from master SASVIEW-996
minor unit test fixes

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