ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since eef298d4 was
3b3b40b,
checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago
|
Merging feature branches
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Rev | Line | |
---|
[3b3b40b] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | import logging |
---|
| 4 | |
---|
| 5 | from PyQt5.QtGui import * |
---|
| 6 | from PyQt5.QtCore import * |
---|
| 7 | from PyQt5.QtWidgets import * |
---|
| 8 | |
---|
| 9 | # set up import paths |
---|
| 10 | import sas.qtgui.path_prepare |
---|
| 11 | |
---|
| 12 | from UnitTesting.TestUtils import QtSignalSpy |
---|
| 13 | |
---|
| 14 | # Local |
---|
| 15 | from sas.qtgui.Utilities.ModelEditor import ModelEditor |
---|
| 16 | from sas.qtgui.Utilities.PythonSyntax import PythonHighlighter |
---|
| 17 | |
---|
| 18 | if not QApplication.instance(): |
---|
| 19 | app = QApplication(sys.argv) |
---|
| 20 | |
---|
| 21 | class 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.