2015-11-15 15:13:40 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
2020-01-01 02:53:08 +00:00
|
|
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
2019-04-13 13:00:22 +00:00
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# 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, either version 3 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# 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, see <https://www.gnu.org/licenses/>. #
|
|
|
|
##########################################################################
|
2015-11-15 15:13:40 +00:00
|
|
|
"""
|
|
|
|
This module contains tests for the CSV Bible importer.
|
|
|
|
"""
|
|
|
|
from unittest import TestCase
|
2017-12-28 08:22:55 +00:00
|
|
|
from unittest.mock import MagicMock
|
2015-11-15 15:13:40 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_remove_message_text(self):
|
2015-11-15 15:13:40 +00:00
|
|
|
"""
|
|
|
|
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
|
2017-12-22 22:20:04 +00:00
|
|
|
assert alert_manager.display_alert.called is False, 'The Alert should not have been called'
|
2015-11-15 15:13:40 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_trigger_message_text(self):
|
2015-11-15 15:13:40 +00:00
|
|
|
"""
|
|
|
|
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
|
2017-12-22 22:20:04 +00:00
|
|
|
assert alert_manager.display_alert.called is True, 'The Alert should have been called'
|
2015-11-15 15:13:40 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_line_break_message_text(self):
|
2015-11-15 15:13:40 +00:00
|
|
|
"""
|
|
|
|
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
|
2017-12-23 09:09:45 +00:00
|
|
|
assert alert_manager.display_alert.called is True, 'The Alert should have been called'
|
2015-11-15 15:13:40 +00:00
|
|
|
alert_manager.display_alert.assert_called_once_with('This is a string')
|