~phill-ridout/openlp/bible_refactors

« back to all changes in this revision

Viewing changes to tests/functional/openlp_plugins/media/test_mediaplugin.py

  • Committer: Phill Ridout
  • Date: 2015-03-14 22:22:10 UTC
  • mfrom: (2507.1.16 openlp)
  • Revision ID: phill.ridout@gmail.com-20150314222210-tx0sdi6sn72yd875
Head

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
"""
 
23
Test the media plugin
 
24
"""
 
25
from unittest import TestCase
 
26
 
 
27
from openlp.core import Registry
 
28
from openlp.plugins.media.mediaplugin import MediaPlugin
 
29
 
 
30
from tests.functional import MagicMock, patch
 
31
from tests.helpers.testmixin import TestMixin
 
32
 
 
33
 
 
34
class MediaPluginTest(TestCase, TestMixin):
 
35
    """
 
36
    Test the media plugin
 
37
    """
 
38
    def setUp(self):
 
39
        Registry.create()
 
40
 
 
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):
 
44
        """
 
45
        Test that the initialise() method overwrites the built-in one, but still calls it
 
46
        """
 
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
 
52
 
 
53
        # WHEN: initialise() is called
 
54
        media_plugin.initialise()
 
55
 
 
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()