← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/media into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/media into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #885150 in OpenLP: "Need non self contained service files"
  https://bugs.launchpad.net/openlp/+bug/885150
  Bug #899714 in OpenLP: "Play/Pause button should be merged"
  https://bugs.launchpad.net/openlp/+bug/899714
  Bug #927829 in OpenLP: "media backends should provide some information about themselves in the settings"
  https://bugs.launchpad.net/openlp/+bug/927829
  Bug #952821 in OpenLP: "Unable to play videos from web"
  https://bugs.launchpad.net/openlp/+bug/952821
  Bug #958198 in OpenLP: "Replacing live background with a video shows theme behind"
  https://bugs.launchpad.net/openlp/+bug/958198
  Bug #999618 in OpenLP: "Video position slider jumps to part way through video"
  https://bugs.launchpad.net/openlp/+bug/999618
  Bug #1022053 in OpenLP: "Previewing media item interferes with live media item"
  https://bugs.launchpad.net/openlp/+bug/1022053
  Bug #1063211 in OpenLP: "Media and Presentation Plugins do not update the service suffix lists if players are added or removed without a restart"
  https://bugs.launchpad.net/openlp/+bug/1063211

For more details, see:
https://code.launchpad.net/~trb143/openlp/media/+merge/145053

Fix up the tests so they work better

Pylint fixes

bug fixes from the conversion
-- 
https://code.launchpad.net/~trb143/openlp/media/+merge/145053
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/media into lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2013-01-23 21:05:25 +0000
+++ openlp/core/lib/mediamanageritem.py	2013-01-26 07:40:29 +0000
@@ -536,7 +536,7 @@
                 translate('OpenLP.MediaManagerItem', 'You must select one or more items.'))
         else:
             log.debug(u'%s Add requested', self.plugin.name)
-            serviceItem = self.plugin.serviceManager.getServiceItem()
+            serviceItem = self.service_manager.getServiceItem()
             if not serviceItem:
                 QtGui.QMessageBox.information(self, UiStrings().NISs,
                     translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.'))
@@ -681,10 +681,11 @@
 
     def _get_service_manager(self):
         """
-        Adds the plugin manager to the class dynamically
+        Adds the service manager to the class dynamically
         """
         if not hasattr(self, u'_service_manager'):
             self._service_manager = Registry().get(u'service_manager')
         return self._service_manager
 
-    service_manager = property(_get_service_manager)
\ No newline at end of file
+    service_manager = property(_get_service_manager)
+

=== modified file 'openlp/core/ui/printserviceform.py'
--- openlp/core/ui/printserviceform.py	2013-01-11 00:19:11 +0000
+++ openlp/core/ui/printserviceform.py	2013-01-26 07:40:29 +0000
@@ -33,7 +33,7 @@
 from PyQt4 import QtCore, QtGui
 from lxml import html
 
-from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings
+from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings, Registry
 from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
 from openlp.core.utils import AppLocation
 
@@ -108,13 +108,11 @@
 
 class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
 
-    def __init__(self, mainWindow, serviceManager):
+    def __init__(self):
         """
         Constructor
         """
-        QtGui.QDialog.__init__(self, mainWindow)
-        self.mainWindow = mainWindow
-        self.serviceManager = serviceManager
+        QtGui.QDialog.__init__(self, self.main_window)
         self.printer = QtGui.QPrinter()
         self.printDialog = QtGui.QPrintDialog(self.printer, self)
         self.document = QtGui.QTextDocument()
@@ -170,7 +168,7 @@
         self._addElement(u'body', parent=html_data)
         self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()),
             html_data.body, classId=u'serviceTitle')
-        for index, item in enumerate(self.serviceManager.serviceItems):
+        for index, item in enumerate(self.service_manager.serviceItems):
             self._addPreviewItem(html_data.body, item[u'service_item'], index)
         # Add the custom service notes:
         if self.footerTextEdit.toPlainText():
@@ -319,14 +317,14 @@
         # remove the icon from the text
         clipboard_text = clipboard_text.replace(u'\ufffc\xa0', u'')
         # and put it all on the clipboard
-        self.mainWindow.clipboard.setText(clipboard_text)
+        self.main_window.clipboard.setText(clipboard_text)
 
     def copyHtmlText(self):
         """
         Copies the display text to the clipboard as Html
         """
         self.update_song_usage()
-        self.mainWindow.clipboard.setText(self.document.toHtml())
+        self.main_window.clipboard.setText(self.document.toHtml())
 
     def printServiceOrder(self):
         """
@@ -392,6 +390,26 @@
         # Only continue when we include the song's text.
         if not self.slideTextCheckBox.isChecked():
             return
-        for item in self.serviceManager.serviceItems:
+        for item in self.service_manager.serviceItems:
             # Trigger Audit requests
             Receiver.send_message(u'print_service_started', [item[u'service_item']])
+
+    def _get_service_manager(self):
+        """
+        Adds the service manager to the class dynamically
+        """
+        if not hasattr(self, u'_service_manager'):
+            self._service_manager = Registry().get(u'service_manager')
+        return self._service_manager
+
+    service_manager = property(_get_service_manager)
+
+    def _get_main_window(self):
+        """
+        Adds the main window to the class dynamically
+        """
+        if not hasattr(self, u'_main_window'):
+            self._main_window = Registry().get(u'main_window')
+        return self._main_window
+
+    main_window = property(_get_main_window)
\ No newline at end of file

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2013-01-24 20:08:52 +0000
+++ openlp/core/ui/servicemanager.py	2013-01-26 07:40:29 +0000
@@ -438,8 +438,8 @@
         log.debug(temp_file_name)
         path_file_name = unicode(self.fileName())
         path, file_name = os.path.split(path_file_name)
-        basename = os.path.splitext(file_name)[0]
-        service_file_name = '%s.osd' % basename
+        base_name = os.path.splitext(file_name)[0]
+        service_file_name = '%s.osd' % base_name
         log.debug(u'ServiceManager.saveFile - %s', path_file_name)
         Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path)
         service = []
@@ -667,11 +667,11 @@
         fileName = unicode(fileName)
         if not os.path.exists(fileName):
             return False
-        zip = None
+        zip_file = None
         fileTo = None
         try:
-            zip = zipfile.ZipFile(fileName)
-            for zipinfo in zip.infolist():
+            zip_file = zipfile.ZipFile(fileName)
+            for zipinfo in zip_file.infolist():
                 try:
                     ucsfile = zipinfo.filename.decode(u'utf-8')
                 except UnicodeDecodeError:
@@ -684,7 +684,7 @@
                     osfile = os.path.split(osfile)[1]
                 log.debug(u'Extract file: %s', osfile)
                 zipinfo.filename = osfile
-                zip.extract(zipinfo, self.servicePath)
+                zip_file.extract(zipinfo, self.servicePath)
                 if osfile.endswith(u'osd'):
                     p_file = os.path.join(self.servicePath, osfile)
             if 'p_file' in locals():
@@ -737,8 +737,8 @@
         finally:
             if fileTo:
                 fileTo.close()
-            if zip:
-                zip.close()
+            if zip_file:
+                zip_file.close()
         self.main_window.finishedProgressBar()
         Receiver.send_message(u'cursor_normal')
         self.repaintServiceList(-1, -1)
@@ -819,6 +819,9 @@
         self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
 
     def onServiceItemNoteForm(self):
+        """
+        Allow the service note to be edited
+        """
         item = self.findServiceItem()[0]
         self.serviceNoteForm.textEdit.setPlainText(
             self.serviceItems[item][u'service_item'].notes)
@@ -1542,7 +1545,7 @@
         """
         Print a Service Order Sheet.
         """
-        settingDialog = PrintServiceForm(self.main_window, self)
+        settingDialog = PrintServiceForm()
         settingDialog.exec_()
 
     def _get_renderer(self):

=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py	2013-01-23 19:53:40 +0000
+++ openlp/core/ui/settingsform.py	2013-01-26 07:40:29 +0000
@@ -140,7 +140,7 @@
         per save.
         """
         if self.resetSuffixes:
-            self.mainWindow.serviceManagerContents.resetSupportedSuffixes()
+            self.service_manager.resetSupportedSuffixes()
             self.resetSuffixes = False
 
     def _get_main_window(self):
@@ -151,4 +151,14 @@
             self._main_window = Registry().get(u'main_window')
         return self._main_window
 
-    main_window = property(_get_main_window)
\ No newline at end of file
+    main_window = property(_get_main_window)
+
+    def _get_service_manager(self):
+        """
+        Adds the plugin manager to the class dynamically
+        """
+        if not hasattr(self, u'_service_manager'):
+            self._service_manager = Registry().get(u'service_manager')
+        return self._service_manager
+
+    service_manager = property(_get_service_manager)
\ No newline at end of file

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2013-01-24 20:08:52 +0000
+++ openlp/core/ui/slidecontroller.py	2013-01-26 07:40:29 +0000
@@ -1190,7 +1190,7 @@
         From the preview display request the Item to be added to service
         """
         if self.serviceItem:
-            self.parent().serviceManagerContents.addServiceItem(self.serviceItem)
+            self.service_manager.addServiceItem(self.serviceItem)
 
     def onGoLiveClick(self):
         """
@@ -1215,7 +1215,7 @@
                 Receiver.send_message('servicemanager_preview_live', u'%s:%s' %
                     (self.serviceItem.unique_identifier, row))
             else:
-                self.parent().liveController.addServiceManagerItem(self.serviceItem, row)
+                self.live_controller.addServiceManagerItem(self.serviceItem, row)
 
     def onMediaStart(self, item):
         """
@@ -1309,3 +1309,22 @@
 
     media_controller = property(_get_media_controller)
 
+    def _get_service_manager(self):
+        """
+        Adds the service manager to the class dynamically
+        """
+        if not hasattr(self, u'_service_manager'):
+            self._service_manager = Registry().get(u'service_manager')
+        return self._service_manager
+
+    service_manager = property(_get_service_manager)
+
+    def _get_live_controller(self):
+        """
+        Adds the live controller to the class dynamically
+        """
+        if not hasattr(self, u'_live_controller'):
+            self._live_controller = Registry().get(u'live_controller')
+        return self._live_controller
+
+    live_controller = property(_get_live_controller)
\ No newline at end of file

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2013-01-23 20:29:43 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2013-01-26 07:40:29 +0000
@@ -189,10 +189,10 @@
 
     def onResetClick(self):
         """
-        Called to reset the Live backgound with the image selected,
+        Called to reset the Live background with the image selected,
         """
         self.resetAction.setVisible(False)
-        self.plugin.liveController.display.resetImage()
+        self.live_controller.display.resetImage()
 
     def liveThemeChanged(self):
         """
@@ -211,7 +211,7 @@
             bitem = self.listView.item(item.row())
             filename = bitem.data(QtCore.Qt.UserRole)
             if os.path.exists(filename):
-                if self.plugin.liveController.display.directImage(filename, background):
+                if self.live_controller.display.directImage(filename, background):
                     self.resetAction.setVisible(True)
                 else:
                     critical_error_message_box(UiStrings().LiveBGError,

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2013-01-23 20:29:43 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2013-01-26 07:40:29 +0000
@@ -131,7 +131,7 @@
         """
         Called to reset the Live background with the media selected,
         """
-        self.live_controller.mediaController.media_reset(self.plugin.liveController)
+        self.media_controller.media_reset(self.live_controller)
         self.resetAction.setVisible(False)
 
     def videobackgroundReplaced(self):
@@ -154,7 +154,7 @@
                 service_item.shortname = service_item.title
                 (path, name) = os.path.split(filename)
                 service_item.add_from_command(path, name,CLAPPERBOARD)
-                if self.live_controller.mediaController.video(DisplayControllerType.Live, service_item,
+                if self.media_controller.video(DisplayControllerType.Live, service_item,
                         videoBehindText=True):
                     self.resetAction.setVisible(True)
                 else:

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2013-01-23 20:29:43 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2013-01-26 07:40:29 +0000
@@ -85,7 +85,7 @@
                 for type in types:
                     if fileType.find(type) == -1:
                         fileType += u'*.%s ' % type
-                        self.plugin.serviceManager.supportedSuffixes(type)
+                        self.service_manager.supportedSuffixes(type)
         self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType
 
     def requiredIcons(self):

=== modified file 'tests/functional/openlp_core_lib/test_registry.py'
--- tests/functional/openlp_core_lib/test_registry.py	2013-01-24 20:04:18 +0000
+++ tests/functional/openlp_core_lib/test_registry.py	2013-01-26 07:40:29 +0000
@@ -13,26 +13,28 @@
 
     def registry_basic_test(self):
         """
-        Test the Service Item basic test
+        Test the registry creation and its usage
         """
         # GIVEN: A new registry
         registry = Registry.create()
 
-        # WHEN: I add a service it should save it
+        # WHEN: I add a component it should save it
         mock_1 = MagicMock()
         Registry().register(u'test1', mock_1)
 
-        # THEN: we should be able retrieve the saved object
+        # THEN: we should be able retrieve the saved component
         assert Registry().get(u'test1') == mock_1, u'The saved service can be retrieved and matches'
 
-        # WHEN: I add a service for the second time I am mad.
-        # THEN  I will get an exception
+        # WHEN: I add a component for the second time I am mad.
+        # THEN  and I will get an exception
         with self.assertRaises(KeyError) as context:
             Registry().register(u'test1', mock_1)
-        self.assertEqual(context.exception[0], u'Duplicate service exception test1')
+        self.assertEqual(context.exception[0], u'Duplicate service exception test1',
+            u'The correct exception has been thrown')
 
-        # WHEN I try to get back a non existent service
+        # WHEN I try to get back a non existent component
         # THEN I will get an exception
         with self.assertRaises(KeyError) as context:
             temp = Registry().get(u'test2')
-        self.assertEqual(context.exception[0], u'Service test2 not found in list')
\ No newline at end of file
+        self.assertEqual(context.exception[0], u'Service test2 not found in list',
+            u'The correct exception has been thrown')

=== modified file 'tests/functional/openlp_core_ui/test_starttimedialog.py'
--- tests/functional/openlp_core_ui/test_starttimedialog.py	2013-01-24 19:08:47 +0000
+++ tests/functional/openlp_core_ui/test_starttimedialog.py	2013-01-26 07:40:29 +0000
@@ -6,7 +6,7 @@
 
 from mock import MagicMock, patch
 from openlp.core.ui import starttimeform
-from PyQt4 import QtGui, QtTest
+from PyQt4 import QtCore, QtGui, QtTest
 
 class TestStartTimeDialog(TestCase):
 
@@ -51,15 +51,32 @@
         mocked_serviceitem = MagicMock()
         mocked_serviceitem.start_time = 61
         mocked_serviceitem.end_time = 3701
+        mocked_serviceitem.media_length = 3701
 
         # WHEN displaying the UI and pressing enter
-        self.form.item = mocked_serviceitem
-        with patch(u'openlp.core.lib.QtGui.QDialog') as MockedQtGuiQDialog:
-            MockedQtGuiQDialog.return_value = True
-            #does not work yet
-            #self.form.exec_()
-
-        # THEN the following values are returned
-        self.assertEqual(self.form.hourSpinBox.value(), 0)
-        self.assertEqual(self.form.minuteSpinBox.value(), 0)
-        self.assertEqual(self.form.secondSpinBox.value(), 0)
\ No newline at end of file
+        self.form.item = {u'service_item': mocked_serviceitem}
+        with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+            self.form.exec_()
+        okWidget = self.form.buttonBox.button(self.form.buttonBox.Ok)
+        QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
+
+        # THEN the following input values values are returned
+        self.assertEqual(self.form.hourSpinBox.value(), 0)
+        self.assertEqual(self.form.minuteSpinBox.value(), 1)
+        self.assertEqual(self.form.secondSpinBox.value(), 1)
+        self.assertEqual(self.form.item[u'service_item'].start_time, 61, u'The start time has not changed')
+
+        # WHEN displaying the UI, changing the time to 2min 3secs and pressing enter
+        self.form.item = {u'service_item': mocked_serviceitem}
+        with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+            self.form.exec_()
+        self.form.minuteSpinBox.setValue(2)
+        self.form.secondSpinBox.setValue(3)
+        okWidget = self.form.buttonBox.button(self.form.buttonBox.Ok)
+        QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
+
+        # THEN the following values values are returned
+        self.assertEqual(self.form.hourSpinBox.value(), 0)
+        self.assertEqual(self.form.minuteSpinBox.value(), 2)
+        self.assertEqual(self.form.secondSpinBox.value(), 3)
+        self.assertEqual(self.form.item[u'service_item'].start_time, 123, u'The start time has changed')
\ No newline at end of file