openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #21077
[Merge] lp:~googol/openlp/presentation-fix into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/presentation-fix into lp:openlp.
Requested reviews:
Andreas Preikschat (googol)
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~googol/openlp/presentation-fix/+merge/175449
Hello,
- fixed presentation file mask
--
https://code.launchpad.net/~googol/openlp/presentation-fix/+merge/175449
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2013-06-20 19:12:55 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2013-07-18 04:56:28 +0000
@@ -59,7 +59,7 @@
self.controllers = controllers
self.icon_path = u'presentations/presentation'
self.Automatic = u''
- MediaManagerItem.__init__(self, parent, plugin)
+ super(PresentationMediaItem, self).__init__(parent, plugin)
self.message_listener = MessageListener(self)
self.has_search = True
self.single_service_item = False
@@ -80,15 +80,15 @@
"""
Build the list of file extensions to be used in the Open file dialog.
"""
- file_type_list = u''
+ file_type_string = u''
for controller in self.controllers:
if self.controllers[controller].enabled():
file_types = self.controllers[controller].supports + self.controllers[controller].also_supports
for file_type in file_types:
- if file_type.find(file_type) == -1:
- file_type_list += u'*.%s ' % file_type
+ if file_type not in file_type_string:
+ file_type_string += u'*.%s ' % file_type
self.service_manager.supported_suffixes(file_type)
- self.on_new_file_masks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % file_type_list
+ self.on_new_file_masks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % file_type_string
def required_icons(self):
"""
=== added directory 'tests/functional/openlp_plugins/presentations'
=== added file 'tests/functional/openlp_plugins/presentations/__init__.py'
=== added file 'tests/functional/openlp_plugins/presentations/test_mediaitem.py'
--- tests/functional/openlp_plugins/presentations/test_mediaitem.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/presentations/test_mediaitem.py 2013-07-18 04:56:28 +0000
@@ -0,0 +1,71 @@
+"""
+This module contains tests for the lib submodule of the Presentations plugin.
+"""
+import os
+from tempfile import mkstemp
+from unittest import TestCase
+
+from mock import patch, MagicMock
+
+from PyQt4 import QtGui
+
+from openlp.core.lib import Registry
+
+from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem
+
+
+class TestMediaItem(TestCase):
+ """
+ Test the mediaitem methods.
+ """
+ def setUp(self):
+ """
+ Set up the components need for all tests.
+ """
+ Registry.create()
+ Registry().register(u'service_manager', MagicMock())
+ Registry().register(u'main_window', MagicMock())
+
+ with patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.__init__') as mocked_init:
+ mocked_init.return_value = None
+ self.media_item = PresentationMediaItem(MagicMock(), MagicMock, MagicMock(), MagicMock())
+
+ self.application = QtGui.QApplication.instance()
+
+ def tearDown(self):
+ """
+ Delete all the C++ objects at the end so that we don't have a segfault
+ """
+ del self.application
+
+ def build_file_mask_string_test(self):
+ """
+ Test the build_file_mask_string() method
+ """
+ # GIVEN: Different controllers.
+ impress_controller = MagicMock()
+ impress_controller.enabled.return_value = True
+ impress_controller.supports = [u'odp']
+ impress_controller.also_supports = [u'ppt']
+ presentation_controller = MagicMock()
+ presentation_controller.enabled.return_value = True
+ presentation_controller.supports = [u'ppt']
+ presentation_controller.also_supports = []
+ presentation_viewer_controller = MagicMock()
+ presentation_viewer_controller.enabled.return_value = False
+ # Mock the controllers.
+ self.media_item.controllers = {
+ u'Impress': impress_controller,
+ u'Powerpoint': presentation_controller,
+ u'Powerpoint Viewer': presentation_viewer_controller
+ }
+
+ # WHEN: Build the file mask.
+ with patch('openlp.plugins.presentations.lib.mediaitem.translate') as mocked_translate:
+ mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
+ self.media_item.build_file_mask_string()
+
+ # THEN: The file mask should be generated.
+ assert self.media_item.on_new_file_masks == u'Presentations (*.odp *.ppt )', \
+ u'The file mask should contain the odp and ppt extensions'
+
=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
--- tests/functional/openlp_plugins/songs/test_mediaitem.py 2013-07-06 20:17:24 +0000
+++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2013-07-18 04:56:28 +0000
@@ -26,7 +26,7 @@
Registry().register(u'service_list', MagicMock())
Registry().register(u'main_window', MagicMock())
with patch('openlp.core.lib.mediamanageritem.MediaManagerItem.__init__'), \
- patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
+ patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
self.media_item = SongMediaItem(MagicMock(), MagicMock())
fd, self.ini_file = mkstemp(u'.ini')
=== modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py'
--- tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2013-04-20 20:30:51 +0000
+++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2013-07-18 04:56:28 +0000
@@ -80,9 +80,7 @@
# GIVEN: Mocked methods.
with patch(u'openlp.plugins.custom.forms.editcustomform.critical_error_message_box') as \
mocked_critical_error_message_box:
- mocked_displayText = MagicMock()
- mocked_displayText.return_value = u''
- self.form.title_edit.displayText = mocked_displayText
+ self.form.title_edit.displayText = MagicMock(return_value=u'')
mocked_setFocus = MagicMock()
self.form.title_edit.setFocus = mocked_setFocus
@@ -101,12 +99,8 @@
# GIVEN: Mocked methods.
with patch(u'openlp.plugins.custom.forms.editcustomform.critical_error_message_box') as \
mocked_critical_error_message_box:
- mocked_displayText = MagicMock()
- mocked_displayText.return_value = u'something'
- self.form.title_edit.displayText = mocked_displayText
- mocked_count = MagicMock()
- mocked_count.return_value = 0
- self.form.slide_list_view.count = mocked_count
+ self.form.title_edit.displayText = MagicMock(return_value=u'something')
+ self.form.slide_list_view.count = MagicMock(return_value=0)
# WHEN: Call the method.
result = self.form._validate()
Follow ups