openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #25484
[Merge] lp:~alisonken1/openlp/bug-1386951 into lp:openlp
Ken Roberts has proposed merging lp:~alisonken1/openlp/bug-1386951 into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Raoul Snyman (raoul-snyman)
Related bugs:
Bug #1386951 in OpenLP: "Fix projector notes"
https://bugs.launchpad.net/openlp/+bug/1386951
For more details, see:
https://code.launchpad.net/~alisonken1/openlp/bug-1386951/+merge/245603
Fix projector edit form that includes text from previous edits.
bugfix 3186951
Bump copyright year
nosetests pass on local checks.
pep8 passes on local checks.
lp:~alisonken1/openlp/bug-1386951 (revision 2466)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/842/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/774/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/720/
[FAILURE] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/624/
Stopping after failure
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/projector/editform.py'
--- openlp/core/ui/projector/editform.py 2014-12-31 10:58:13 +0000
+++ openlp/core/ui/projector/editform.py 2015-01-05 19:03:31 +0000
@@ -132,6 +132,7 @@
self.location_label.setText(translate('OpenLP.ProjectorEditForm', 'Location'))
self.location_text.setText(self.projector.location)
self.notes_label.setText(translate('OpenLP.ProjectorEditForm', 'Notes'))
+ self.notes_text.clear()
self.notes_text.insertPlainText(self.projector.notes)
@@ -167,7 +168,6 @@
self.new_projector = False
self.retranslateUi(self)
reply = QDialog.exec_(self)
- self.projector = None
return reply
@pyqtSlot()
=== modified file 'openlp/core/ui/projector/manager.py'
--- openlp/core/ui/projector/manager.py 2014-12-31 10:58:13 +0000
+++ openlp/core/ui/projector/manager.py 2015-01-05 19:03:31 +0000
@@ -562,9 +562,8 @@
return
self.old_projector = projector
projector.link.disconnect_from_host()
- record = self.projectordb.get_projector_by_ip(projector.link.ip)
- self.projector_form.exec_(record)
- new_record = self.projectordb.get_projector_by_id(record.id)
+ self.projector_form.exec_(projector.db_item)
+ projector.db_item = self.projectordb.get_projector_by_id(self.old_projector.db_item.id)
def on_poweroff_projector(self, opt=None):
"""
=== added file 'tests/interfaces/openlp_core_ui/test_projectoreditform.py'
--- tests/interfaces/openlp_core_ui/test_projectoreditform.py 1970-01-01 00:00:00 +0000
+++ tests/interfaces/openlp_core_ui/test_projectoreditform.py 2015-01-05 19:03:31 +0000
@@ -0,0 +1,118 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2015 Raoul Snyman #
+# Portions copyright (c) 2008-2015 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Ken Roberts, Simon Scudder, #
+# Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
+# Dave Warnock, Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+"""
+Interface tests to test the openlp.core.ui.projector.editform.ProjectorEditForm()
+class and methods.
+"""
+
+import os
+import tempfile
+from unittest import TestCase
+
+from openlp.core.common import Registry, Settings
+from openlp.core.lib.projector.db import Projector, ProjectorDB
+from openlp.core.ui import ProjectorEditForm
+
+from tests.functional import patch
+from tests.helpers.testmixin import TestMixin
+from tests.resources.projector.data import TEST1_DATA, TEST2_DATA
+
+tmpfile = tempfile.mkstemp(prefix='openlp-test-projectormanager', suffix='.sql')[1]
+
+
+class TestProjectorEditForm(TestCase, TestMixin):
+ """
+ Test the methods in the ProjectorEditForm class
+ """
+ def setUp(self):
+ """
+ Create the UI and setup necessary options
+
+ :return: None
+ """
+ self.build_settings()
+ self.setup_application()
+ Registry.create()
+ if not hasattr(self, 'projector_form'):
+ with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
+ mocked_init_url.start()
+ mocked_init_url.return_value = 'sqlite:///{}'.format(tmpfile)
+ self.projectordb = ProjectorDB()
+ if not hasattr(self, 'projector_edit_form'):
+ self.projector_form = ProjectorEditForm(projectordb=self.projectordb)
+
+ def tearDown(self):
+ """
+ Close database session.
+ Delete all C++ objects at end so we don't segfault.
+
+ :return: None
+ """
+ self.projectordb.session.close()
+ del(self.projector_form)
+ os.remove(tmpfile)
+ self.destroy_settings()
+
+ def edit_form_add_projector_test(self):
+ """
+ Test projector edit form with no parameters creates a new entry.
+
+ :return: None
+ """
+ # GIVEN: Mocked setup
+ with patch('openlp.core.ui.projector.editform.QDialog.exec_'):
+
+ # WHEN: Calling edit form with no parameters
+ self.projector_form.exec_()
+ item = self.projector_form.projector
+
+ # THEN: Should be creating a new instance
+ self.assertTrue(self.projector_form.new_projector,
+ 'Projector edit form should be marked as a new entry')
+ self.assertTrue((item.ip is None and item.name is None),
+ 'Projector edit form should have a new Projector() instance to edit')
+
+ def edit_form_edit_projector_test(self):
+ """
+ Test projector edit form with existing projector entry
+
+ :return:
+ """
+ # GIVEN: Mocked setup
+ with patch('openlp.core.ui.projector.editform.QDialog.exec_'):
+
+ # WHEN: Calling edit form with existing projector instance
+ self.projector_form.exec_(projector=TEST1_DATA)
+ item = self.projector_form.projector
+
+ # THEN: Should be editing an existing entry
+ self.assertFalse(self.projector_form.new_projector,
+ 'Projector edit form should be marked as existing entry')
+ self.assertTrue((item.ip is TEST1_DATA.ip and item.name is TEST1_DATA.name),
+ 'Projector edit form should have TEST1_DATA() instance to edit')
Follow ups