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

Last change on this file since 5dba493 was 53c771e, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Converted unit tests

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[6d05e1d]1import sys
2import unittest
3
[53c771e]4from PyQt5 import QtGui, QtWidgets
[6d05e1d]5
6# set up import paths
[83eb5208]7import sas.qtgui.path_prepare
[6d05e1d]8
9# Local
[83eb5208]10from sas.qtgui.Plotting.ScaleProperties import ScaleProperties
[6d05e1d]11
[53c771e]12if not QtWidgets.QApplication.instance():
13    app = QtWidgets.QApplication(sys.argv)
[6d05e1d]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'''
[53c771e]29        self.assertIsInstance(self.widget, QtWidgets.QDialog)
[6d05e1d]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(), 6)
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(5)
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.