source: sasview/src/sas/qtgui/UnitTesting/SetGraphRangeTest.py @ a9b568c

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 a9b568c was d3ca363, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

Setting graph range - SASVIEW-381

  • Property mode set to 100755
File size: 1.8 KB
Line 
1import sys
2import unittest
3
4from PyQt4 import QtGui
5
6# set up import paths
7import path_prepare
8
9# Local
10from SetGraphRange import SetGraphRange
11
12app = QtGui.QApplication(sys.argv)
13
14class SetGraphRangeTest(unittest.TestCase):
15    '''Test the SetGraphRange'''
16    def setUp(self):
17        '''Create the SetGraphRange'''
18
19        self.widget = SetGraphRange(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(), "Set Graph Range")
30        self.assertIsInstance(self.widget.txtXmin, QtGui.QLineEdit)
31        self.assertIsInstance(self.widget.txtXmin.validator(), QtGui.QDoubleValidator)
32       
33    def testGoodRanges(self):
34        '''Test the X range values set by caller''' 
35        self.assertEqual(self.widget.xrange(), (0.0, 0.0))
36        self.assertEqual(self.widget.yrange(), (0.0, 0.0))
37
38        new_widget = SetGraphRange(None, ("1.0", 2.0), (8.0, "-2"))
39        self.assertEqual(new_widget.xrange(), (1.0, 2.0))
40        self.assertEqual(new_widget.yrange(), (8.0, -2.0))
41
42
43    def testBadRanges(self):
44        '''Test the incorrect X range values set by caller'''
45        with self.assertRaises(ValueError):
46            new_widget = SetGraphRange(None, ("1.0", "aa"), (None, "@"))
47            self.assertEqual(new_widget.xrange(), (1.0, 0.0))
48            self.assertEqual(new_widget.yrange(), (0.0, 0.0))
49
50        with self.assertRaises(AssertionError):
51            new_widget = SetGraphRange(None, "I'm a tuple", None)
52            self.assertEqual(new_widget.xrange(), (1.0, 0.0))
53            self.assertEqual(new_widget.yrange(), (0.0, 0.0))
54
55if __name__ == "__main__":
56    unittest.main()
Note: See TracBrowser for help on using the repository browser.