source: sasview/src/sas/qtgui/UnitTesting/GuiUtilsTest.py @ a281ab8

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

Prototype DE↔perspective api based on QStandardItem.

  • Property mode set to 100755
File size: 2.1 KB
Line 
1import sys
2import unittest
3
4# Tested module
5from GuiUtils import *
6
7class GuiUtilsTest(unittest.TestCase):
8    '''Test the GUI Utilities methods'''
9    def setUp(self):
10        '''Empty'''
11        pass
12
13    def tearDown(self):
14        '''empty'''
15        pass
16
17    def testDefaults(self):
18        """
19        Test all the global constants defined in the file.
20        """
21        # Should probably test the constants in the file,
22        # but this will done after trimming down GuiUtils
23        # and retaining only necessary variables.
24        pass
25
26    def testGetAppDir(self):
27        """
28        """
29        pass
30
31    def testGetUserDirectory(self):
32        """
33        Simple test of user directory getter
34        """
35        home_dir = os.path.expanduser("~")
36        self.assertIn(home_dir, get_user_directory())
37
38    def testCommunicate(self):
39        """
40        Test the container class with signal definitions
41        """
42        com = Communicate()
43
44        # All defined signals
45        list_of_signals = [
46            'fileReadSignal',
47            'fileDataReceivedSignal',
48            'statusBarUpdateSignal',
49            'updatePerspectiveWithDataSignal',
50            'updateModelFromPerspectiveSignal'
51        ]
52
53        # Assure all signals are defined.
54        for signal in list_of_signals:
55            self.assertIn(signal, dir(com))
56
57
58    def testUpdateModelItem(self):
59        """
60        Test the QModelItem update method
61        """
62        test_item = QtGui.QStandardItem()
63        test_list = ['aa','11']
64        update_data = QtCore.QVariant(test_list)
65        name = "Black Sabbath"
66
67        # update the item
68        updateModelItem(test_item, update_data, name)
69       
70        # Make sure test_item got all data added
71        self.assertEqual(test_item.child(0).text(), name)
72        self.assertTrue(test_item.child(0).isCheckable())
73        list_from_item = test_item.child(0).child(0).data().toPyObject()
74        self.assertIsInstance(list_from_item, list)
75        self.assertEqual(str(list_from_item[0]), test_list[0])
76        self.assertEqual(str(list_from_item[1]), test_list[1])
77
78if __name__ == "__main__":
79    unittest.main()
80
Note: See TracBrowser for help on using the repository browser.