1 | import sys |
---|
2 | import unittest |
---|
3 | |
---|
4 | from PyQt4 import QtGui |
---|
5 | |
---|
6 | # set up import paths |
---|
7 | import sas.qtgui.path_prepare |
---|
8 | |
---|
9 | # Local |
---|
10 | from sas.qtgui.Plotting.ScaleProperties import ScaleProperties |
---|
11 | |
---|
12 | app = QtGui.QApplication(sys.argv) |
---|
13 | |
---|
14 | class 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 | |
---|
59 | if __name__ == "__main__": |
---|
60 | unittest.main() |
---|