1
# -*- coding: utf-8 -*-
2
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
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. #
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 #
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
###############################################################################
25
from unittest import TestCase
27
from openlp.core import Registry
28
from openlp.plugins.media.mediaplugin import MediaPlugin
30
from tests.functional import MagicMock, patch
31
from tests.helpers.testmixin import TestMixin
34
class MediaPluginTest(TestCase, TestMixin):
41
@patch(u'openlp.plugins.media.mediaplugin.Plugin.initialise')
42
@patch(u'openlp.plugins.media.mediaplugin.Settings')
43
def initialise_test(self, MockedSettings, mocked_initialise):
45
Test that the initialise() method overwrites the built-in one, but still calls it
47
# GIVEN: A media plugin instance and a mocked settings object
48
media_plugin = MediaPlugin()
49
mocked_settings = MagicMock()
50
mocked_settings.get_files_from_config.return_value = True # Not the real value, just need something "true-ish"
51
MockedSettings.return_value = mocked_settings
53
# WHEN: initialise() is called
54
media_plugin.initialise()
56
# THEN: The settings should be upgraded and the base initialise() method should be called
57
mocked_settings.get_files_from_config.assert_called_with(media_plugin)
58
mocked_settings.setValue.assert_called_with('media/media files', True)
59
mocked_initialise.assert_called_with()