openlp/tests/openlp_plugins/media/test_mediaplugin.py

54 lines
2.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
2020-12-30 21:42:49 +00:00
# Copyright (c) 2008-2021 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/>. #
##########################################################################
"""
Test the media plugin
"""
2017-10-10 07:08:44 +00:00
from unittest.mock import patch
2020-10-19 07:18:26 +00:00
from openlp.core.state import State
2018-12-01 14:41:40 +00:00
from openlp.plugins.media.mediaplugin import MediaPlugin
@patch('openlp.plugins.media.mediaplugin.Plugin.initialise')
def test_initialise(mock_initialise, state, settings):
"""
Test that the initialise() method overwrites the built-in one, but still calls it
"""
# GIVEN: A media plugin instance
2020-10-19 07:18:26 +00:00
State().add_service('mediacontroller', 0)
State().update_pre_conditions('mediacontroller', True)
media_plugin = MediaPlugin()
# WHEN: initialise() is called
media_plugin.initialise()
# THEN: The the base initialise() method should be called
mock_initialise.assert_called_with()
def test_about_text():
# GIVEN: The MediaPlugin
# WHEN: Retrieving the about text
# THEN: about() should return a string object
assert isinstance(MediaPlugin.about(), str)
# THEN: about() should return a non-empty string
assert len(MediaPlugin.about()) != 0