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

Proposed by Tim Bentley
Status: Merged
Merged at revision: 2567
Proposed branch: lp:~trb143/openlp/bug-1516171-24
Merge into: lp:openlp
Diff against target: 132 lines (+110/-1)
3 files modified
openlp/plugins/alerts/lib/alertsmanager.py (+5/-1)
tests/functional/openlp_plugins/alerts/__init__.py (+21/-0)
tests/functional/openlp_plugins/alerts/test_manager.py (+84/-0)
To merge this branch: bzr merge lp:~trb143/openlp/bug-1516171-24
Reviewer Review Type Date Requested Status
Tomas Groth Approve
Review via email: mp+277519@code.launchpad.net

Description of the change

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/

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/alerts/lib/alertsmanager.py'
2--- openlp/plugins/alerts/lib/alertsmanager.py 2015-03-09 20:57:39 +0000
3+++ openlp/plugins/alerts/lib/alertsmanager.py 2015-11-15 15:18:52 +0000
4@@ -48,7 +48,11 @@
5 :param message: The message text to be displayed
6 """
7 if message:
8- self.display_alert(message[0])
9+ text = message[0]
10+ # remove line breaks as these crash javascript code on display
11+ while '\n' in text:
12+ text = text.replace('\n', ' ')
13+ self.display_alert(text)
14
15 def display_alert(self, text=''):
16 """
17
18=== added directory 'tests/functional/openlp_plugins/alerts'
19=== added file 'tests/functional/openlp_plugins/alerts/__init__.py'
20--- tests/functional/openlp_plugins/alerts/__init__.py 1970-01-01 00:00:00 +0000
21+++ tests/functional/openlp_plugins/alerts/__init__.py 2015-11-15 15:18:52 +0000
22@@ -0,0 +1,21 @@
23+# -*- coding: utf-8 -*-
24+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
25+
26+###############################################################################
27+# OpenLP - Open Source Lyrics Projection #
28+# --------------------------------------------------------------------------- #
29+# Copyright (c) 2008-2015 OpenLP Developers #
30+# --------------------------------------------------------------------------- #
31+# This program is free software; you can redistribute it and/or modify it #
32+# under the terms of the GNU General Public License as published by the Free #
33+# Software Foundation; version 2 of the License. #
34+# #
35+# This program is distributed in the hope that it will be useful, but WITHOUT #
36+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
37+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
38+# more details. #
39+# #
40+# You should have received a copy of the GNU General Public License along #
41+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
42+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
43+###############################################################################
44
45=== added file 'tests/functional/openlp_plugins/alerts/test_manager.py'
46--- tests/functional/openlp_plugins/alerts/test_manager.py 1970-01-01 00:00:00 +0000
47+++ tests/functional/openlp_plugins/alerts/test_manager.py 2015-11-15 15:18:52 +0000
48@@ -0,0 +1,84 @@
49+# -*- coding: utf-8 -*-
50+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
51+
52+###############################################################################
53+# OpenLP - Open Source Lyrics Projection #
54+# --------------------------------------------------------------------------- #
55+# Copyright (c) 2008-2015 OpenLP Developers #
56+# --------------------------------------------------------------------------- #
57+# This program is free software; you can redistribute it and/or modify it #
58+# under the terms of the GNU General Public License as published by the Free #
59+# Software Foundation; version 2 of the License. #
60+# #
61+# This program is distributed in the hope that it will be useful, but WITHOUT #
62+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
63+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
64+# more details. #
65+# #
66+# You should have received a copy of the GNU General Public License along #
67+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
68+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
69+###############################################################################
70+"""
71+This module contains tests for the CSV Bible importer.
72+"""
73+
74+import os
75+import json
76+from unittest import TestCase
77+
78+from tests.functional import MagicMock, patch
79+from openlp.core.common.registry import Registry
80+from openlp.plugins.alerts.lib.alertsmanager import AlertsManager
81+
82+
83+class TestAlertManager(TestCase):
84+
85+ def setUp(self):
86+ """
87+ Create the UI
88+ """
89+ Registry.create()
90+
91+ def remove_message_text_test(self):
92+ """
93+ Test that Alerts are not triggered with empty strings
94+ """
95+ # GIVEN: A valid Alert Manager
96+ alert_manager = AlertsManager(None)
97+ alert_manager.display_alert = MagicMock()
98+
99+ # WHEN: Called with an empty string
100+ alert_manager.alert_text('')
101+
102+ # THEN: the display should not have been triggered
103+ self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
104+
105+ def trigger_message_text_test(self):
106+ """
107+ Test that Alerts are triggered with a text string
108+ """
109+ # GIVEN: A valid Alert Manager
110+ alert_manager = AlertsManager(None)
111+ alert_manager.display_alert = MagicMock()
112+
113+ # WHEN: Called with an empty string
114+ alert_manager.alert_text(['This is a string'])
115+
116+ # THEN: the display should have been triggered
117+ self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
118+
119+ def line_break_message_text_test(self):
120+ """
121+ Test that Alerts are triggered with a text string but line breaks are removed
122+ """
123+ # GIVEN: A valid Alert Manager
124+ alert_manager = AlertsManager(None)
125+ alert_manager.display_alert = MagicMock()
126+
127+ # WHEN: Called with an empty string
128+ alert_manager.alert_text(['This is \n a string'])
129+
130+ # THEN: the display should have been triggered
131+ self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
132+ alert_manager.display_alert.assert_called_once_with('This is a string')