openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #25667
[Merge] lp:~alisonken1/openlp/projector_source_edit_fix into lp:openlp
Ken Roberts has proposed merging lp:~alisonken1/openlp/projector_source_edit_fix into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~alisonken1/openlp/projector_source_edit_fix/+merge/246862
Fix invalid call to QMessageBox() when user wants to delete user-defined source text.
Added tests
lp:~alisonken1/openlp/projector_source_edit_fix (revision 2480)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/875/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/807/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/753/
[SUCCESS] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/664/
[SUCCESS] http://ci.openlp.org/job/Branch-04b-Windows_Interface_Tests/263/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/412/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/283/
May affect translators.
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/projector/sourceselectform.py'
--- openlp/core/ui/projector/sourceselectform.py 2014-12-31 10:58:13 +0000
+++ openlp/core/ui/projector/sourceselectform.py 2015-01-19 04:32:32 +0000
@@ -339,8 +339,7 @@
msg = QtGui.QMessageBox()
msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
msg.setInformativeText(translate('OpenLP.SourceSelectForm',
- 'Are you sure you want to delete ALL user-defined '),
- translate('OpenLP.SourceSelectForm',
+ 'Are you sure you want to delete ALL user-defined '
'source input text for this projector?'))
msg.setStandardButtons(msg.Cancel | msg.Ok)
msg.setDefaultButton(msg.Cancel)
@@ -478,8 +477,7 @@
msg = QtGui.QMessageBox()
msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
msg.setInformativeText(translate('OpenLP.SourceSelectForm',
- 'Are you sure you want to delete ALL user-defined '),
- translate('OpenLP.SourceSelectForm',
+ 'Are you sure you want to delete ALL user-defined '
'source input text for this projector?'))
msg.setStandardButtons(msg.Cancel | msg.Ok)
msg.setDefaultButton(msg.Cancel)
=== modified file 'tests/interfaces/openlp_core_ui/test_projectorsourceform.py'
--- tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2015-01-19 04:32:32 +0000
@@ -36,11 +36,18 @@
log.debug('test_projectorsourceform loaded')
from unittest import TestCase
+from PyQt4 import QtGui
+from PyQt4.QtGui import QDialog
+from tests.functional import patch
+from tests.functional.openlp_core_lib.test_projectordb import tmpfile
from tests.helpers.testmixin import TestMixin
+from tests.resources.projector.data import TEST_DB, TEST1_DATA
+
+from openlp.core.common import Registry, Settings
+from openlp.core.lib.projector.db import ProjectorDB
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
-
-from openlp.core.ui.projector.sourceselectform import source_group
+from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
def build_source_dict():
@@ -61,6 +68,37 @@
"""
Test class for the Projector Source Select form module
"""
+ @patch('openlp.core.lib.projector.db.init_url')
+ def setUp(self, mocked_init_url):
+ """
+ Set up anything necessary for all tests
+ """
+ mocked_init_url.start()
+ mocked_init_url.return_value = 'sqlite:///{}'.format(tmpfile)
+ self.build_settings()
+ self.setup_application()
+ Registry.create()
+ # Do not try to recreate if we've already been created from a previous test
+ if not hasattr(self, 'projectordb'):
+ self.projectordb = ProjectorDB()
+ # Retrieve/create a database record
+ self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA.ip)
+ if not self.projector:
+ self.projectordb.add_projector(projector=TEST1_DATA)
+ self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA.ip)
+ self.projector.dbid = self.projector.id
+ self.projector.db_item = self.projector
+
+ def tearDown(self):
+ """
+ Close database session.
+ Delete all C++ objects at end so we don't segfault.
+ """
+ self.projectordb.session.close()
+ del(self.projectordb)
+ del(self.projector)
+ self.destroy_settings()
+
def source_dict_test(self):
"""
Test that source list dict returned from sourceselectform module is a valid dict with proper entries
@@ -77,3 +115,43 @@
# THEN: return dictionary should match test dictionary
self.assertEquals(check, build_source_dict(),
"Source group dictionary should match test dictionary")
+
+ @patch.object(QDialog, 'exec_')
+ def source_select_edit_button_test(self, mocked_qdialog):
+ """
+ Test source select form edit has Ok, Cancel, Reset, and Revert buttons
+ """
+ # GIVEN: Initial setup and mocks
+ self.projector.source_available = ['11', ]
+ self.projector.source = '11'
+
+ # WHEN we create a source select widget and set edit=True
+ select_form = SourceSelectSingle(parent=None, projectordb=self.projectordb)
+ select_form.edit = True
+ select_form.exec_(projector=self.projector)
+ projector = select_form.projector
+
+ # THEN: Verify all 4 buttons are available
+ self.assertEquals(len(select_form.button_box.buttons()), 4,
+ 'SourceSelect dialog box should have "OK", "Cancel" '
+ '"Rest", and "Revert" buttons available')
+
+ @patch.object(QDialog, 'exec_')
+ def source_select_noedit_button_test(self, mocked_qdialog):
+ """
+ Test source select form view has OK and Cancel buttons only
+ """
+ # GIVEN: Initial setup and mocks
+ self.projector.source_available = ['11', ]
+ self.projector.source = '11'
+
+ # WHEN we create a source select widget and set edit=False
+ select_form = SourceSelectSingle(parent=None, projectordb=self.projectordb)
+ select_form.edit = False
+ select_form.exec_(projector=self.projector)
+ projector = select_form.projector
+
+ # THEN: Verify only 2 buttons are available
+ self.assertEquals(len(select_form.button_box.buttons()), 2,
+ 'SourceSelect dialog box should only have "OK" '
+ 'and "Cancel" buttons available')
=== modified file 'tests/resources/projector/data.py'
--- tests/resources/projector/data.py 2014-12-31 10:58:13 +0000
+++ tests/resources/projector/data.py 2015-01-19 04:32:32 +0000
@@ -30,9 +30,12 @@
The :mod:`tests.resources.projector.data file contains test data
"""
+import os
from openlp.core.lib.projector.db import Projector
# Test data
+TEST_DB = os.path.join('tmp', 'openlp-test-projectordb.sql')
+
TEST1_DATA = Projector(ip='111.111.111.111',
port='1111',
pin='1111',
Follow ups