source: sasview/src/sas/qtgui/Utilities/UnitTesting/ModelEditorTest.py @ 3b3b40b

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 3b3b40b was 3b3b40b, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

Merging feature branches

  • Property mode set to 100755
File size: 1.3 KB
Line 
1import sys
2import unittest
3import logging
4
5from PyQt5.QtGui import *
6from PyQt5.QtCore import *
7from PyQt5.QtWidgets import *
8
9# set up import paths
10import sas.qtgui.path_prepare
11
12from UnitTesting.TestUtils import QtSignalSpy
13
14# Local
15from sas.qtgui.Utilities.ModelEditor import ModelEditor
16from sas.qtgui.Utilities.PythonSyntax import PythonHighlighter
17
18if not QApplication.instance():
19    app = QApplication(sys.argv)
20
21class ModelEditorTest(unittest.TestCase):
22    def setUp(self):
23        """
24        Prepare the editor
25        """
26        self.widget = ModelEditor(None)
27
28    def tearDown(self):
29        """Destroy the DataOperationUtility"""
30        self.widget.close()
31        self.widget = None
32
33    def testDefaults(self):
34        """Test the GUI in its default state"""
35        self.assertIsInstance(self.widget.highlight, PythonHighlighter)
36
37    def testEdit(self):
38        """Test that a signal is emitted on edit"""
39        spy_signal = QtSignalSpy(self.widget, self.widget.modelModified)
40
41        # Edit text
42        text = "test"
43        self.widget.txtEditor.setPlainText(text)
44
45        # Assure the signal got emitted
46        self.assertEqual(spy_signal.count(), 1)
47
48        # Assure getModel() returns right content
49        self.assertTrue(text, self.widget.txtEditor.toPlainText())
50
51
Note: See TracBrowser for help on using the repository browser.