← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bug-1516171-24 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bug-1516171-24 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1516171 in OpenLP: "Alert with more than one line in Android app makes desktop report a bug"
  https://bugs.launchpad.net/openlp/+bug/1516171

For more details, see:
https://code.launchpad.net/~trb143/openlp/bug-1516171-24/+merge/277519

Remove \n for remotes posts to alerts to stop abends in maindisplay

lp:~trb143/openlp/bug-1516171-24 (revision 2567)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/1180/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/1103/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/1044/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/891/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/487/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/603/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/474/


-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bug-1516171-24 into lp:openlp.
=== modified file 'openlp/plugins/alerts/lib/alertsmanager.py'
--- openlp/plugins/alerts/lib/alertsmanager.py	2015-03-09 20:57:39 +0000
+++ openlp/plugins/alerts/lib/alertsmanager.py	2015-11-15 15:18:52 +0000
@@ -48,7 +48,11 @@
         :param message: The message text to be displayed
         """
         if message:
-            self.display_alert(message[0])
+            text = message[0]
+            # remove line breaks as these crash javascript code on display
+            while '\n' in text:
+                text = text.replace('\n', ' ')
+            self.display_alert(text)
 
     def display_alert(self, text=''):
         """

=== added directory 'tests/functional/openlp_plugins/alerts'
=== added file 'tests/functional/openlp_plugins/alerts/__init__.py'
--- tests/functional/openlp_plugins/alerts/__init__.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/alerts/__init__.py	2015-11-15 15:18:52 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2015 OpenLP Developers                                   #
+# --------------------------------------------------------------------------- #
+# 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                          #
+###############################################################################

=== added file 'tests/functional/openlp_plugins/alerts/test_manager.py'
--- tests/functional/openlp_plugins/alerts/test_manager.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/alerts/test_manager.py	2015-11-15 15:18:52 +0000
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2015 OpenLP Developers                                   #
+# --------------------------------------------------------------------------- #
+# 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                          #
+###############################################################################
+"""
+This module contains tests for the CSV Bible importer.
+"""
+
+import os
+import json
+from unittest import TestCase
+
+from tests.functional import MagicMock, patch
+from openlp.core.common.registry import Registry
+from openlp.plugins.alerts.lib.alertsmanager import AlertsManager
+
+
+class TestAlertManager(TestCase):
+
+    def setUp(self):
+        """
+        Create the UI
+        """
+        Registry.create()
+
+    def remove_message_text_test(self):
+        """
+        Test that Alerts are not triggered with empty strings
+        """
+        # GIVEN: A valid Alert Manager
+        alert_manager = AlertsManager(None)
+        alert_manager.display_alert = MagicMock()
+
+        # WHEN: Called with an empty string
+        alert_manager.alert_text('')
+
+        # THEN: the display should not have been triggered
+        self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
+
+    def trigger_message_text_test(self):
+        """
+        Test that Alerts are triggered with a text string
+        """
+        # GIVEN: A valid Alert Manager
+        alert_manager = AlertsManager(None)
+        alert_manager.display_alert = MagicMock()
+
+        # WHEN: Called with an empty string
+        alert_manager.alert_text(['This is a string'])
+
+        # THEN: the display should have been triggered
+        self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
+
+    def line_break_message_text_test(self):
+        """
+        Test that Alerts are triggered with a text string but line breaks are removed
+        """
+        # GIVEN: A valid Alert Manager
+        alert_manager = AlertsManager(None)
+        alert_manager.display_alert = MagicMock()
+
+        # WHEN: Called with an empty string
+        alert_manager.alert_text(['This is \n a string'])
+
+        # THEN: the display should have been triggered
+        self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
+        alert_manager.display_alert.assert_called_once_with('This is   a string')


Follow ups