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
=== 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 @@
48 :param message: The message text to be displayed48 :param message: The message text to be displayed
49 """49 """
50 if message:50 if message:
51 self.display_alert(message[0])51 text = message[0]
52 # remove line breaks as these crash javascript code on display
53 while '\n' in text:
54 text = text.replace('\n', ' ')
55 self.display_alert(text)
5256
53 def display_alert(self, text=''):57 def display_alert(self, text=''):
54 """58 """
5559
=== 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 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2015 OpenLP Developers #
8# --------------------------------------------------------------------------- #
9# This program is free software; you can redistribute it and/or modify it #
10# under the terms of the GNU General Public License as published by the Free #
11# Software Foundation; version 2 of the License. #
12# #
13# This program is distributed in the hope that it will be useful, but WITHOUT #
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
16# more details. #
17# #
18# You should have received a copy of the GNU General Public License along #
19# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################
022
=== 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 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2015 OpenLP Developers #
8# --------------------------------------------------------------------------- #
9# This program is free software; you can redistribute it and/or modify it #
10# under the terms of the GNU General Public License as published by the Free #
11# Software Foundation; version 2 of the License. #
12# #
13# This program is distributed in the hope that it will be useful, but WITHOUT #
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
16# more details. #
17# #
18# You should have received a copy of the GNU General Public License along #
19# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################
22"""
23This module contains tests for the CSV Bible importer.
24"""
25
26import os
27import json
28from unittest import TestCase
29
30from tests.functional import MagicMock, patch
31from openlp.core.common.registry import Registry
32from openlp.plugins.alerts.lib.alertsmanager import AlertsManager
33
34
35class TestAlertManager(TestCase):
36
37 def setUp(self):
38 """
39 Create the UI
40 """
41 Registry.create()
42
43 def remove_message_text_test(self):
44 """
45 Test that Alerts are not triggered with empty strings
46 """
47 # GIVEN: A valid Alert Manager
48 alert_manager = AlertsManager(None)
49 alert_manager.display_alert = MagicMock()
50
51 # WHEN: Called with an empty string
52 alert_manager.alert_text('')
53
54 # THEN: the display should not have been triggered
55 self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
56
57 def trigger_message_text_test(self):
58 """
59 Test that Alerts are triggered with a text string
60 """
61 # GIVEN: A valid Alert Manager
62 alert_manager = AlertsManager(None)
63 alert_manager.display_alert = MagicMock()
64
65 # WHEN: Called with an empty string
66 alert_manager.alert_text(['This is a string'])
67
68 # THEN: the display should have been triggered
69 self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
70
71 def line_break_message_text_test(self):
72 """
73 Test that Alerts are triggered with a text string but line breaks are removed
74 """
75 # GIVEN: A valid Alert Manager
76 alert_manager = AlertsManager(None)
77 alert_manager.display_alert = MagicMock()
78
79 # WHEN: Called with an empty string
80 alert_manager.alert_text(['This is \n a string'])
81
82 # THEN: the display should have been triggered
83 self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
84 alert_manager.display_alert.assert_called_once_with('This is a string')