← 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/145026

Fix up the tests so they work better

Pylint fixes

bug fixes from the conversion
-- 
https://code.launchpad.net/~trb143/openlp/media/+merge/145026
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/media into lp:openlp.
=== 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-25 20:53:22 +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)

=== 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-25 20:53:22 +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/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-25 20:53:22 +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-25 20:53:22 +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 '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-25 20:53:22 +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-25 20:53:22 +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