openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #24209
[Merge] lp:~phill-ridout/openlp/bug1222534 into lp:openlp
Phill has proposed merging lp:~phill-ridout/openlp/bug1222534 into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Tomas Groth (tomasgroth)
Related bugs:
Bug #1222534 in OpenLP: "KeyError when "Allow presentation application to be overridden" and Spanish language is selected"
https://bugs.launchpad.net/openlp/+bug/1222534
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/bug1222534/+merge/233691
Fixes bug 1222534 by using userdata rather than relying on a translated string
lp:~phill-ridout/openlp/bug1222534 (revision 2390)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/496/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/454/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/399/
[SUCCESS] http://ci.openlp.org/job/Branch-04-Windows_Tests/358/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/238/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/112/
--
https://code.launchpad.net/~phill-ridout/openlp/bug1222534/+merge/233691
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2014-06-05 16:25:37 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2014-09-08 10:08:15 +0000
@@ -145,7 +145,7 @@
if self.controllers[item].enabled():
self.display_type_combo_box.addItem(item)
if self.display_type_combo_box.count() > 1:
- self.display_type_combo_box.insertItem(0, self.automatic)
+ self.display_type_combo_box.insertItem(0, self.automatic, userData='automatic')
self.display_type_combo_box.setCurrentIndex(0)
if Settings().value(self.settings_section + '/override app') == QtCore.Qt.Checked:
self.presentation_widget.show()
@@ -312,7 +312,7 @@
(path, name) = os.path.split(filename)
service_item.title = name
if os.path.exists(filename):
- if service_item.processor == self.automatic:
+ if self.display_type_combo_box.itemData(self.display_type_combo_box.currentIndex()) == 'automatic':
service_item.processor = self.find_controller_by_type(filename)
if not service_item.processor:
return False
=== modified file 'tests/functional/openlp_plugins/presentations/test_presentationcontroller.py'
--- tests/functional/openlp_plugins/presentations/test_presentationcontroller.py 2014-03-13 20:59:10 +0000
+++ tests/functional/openlp_plugins/presentations/test_presentationcontroller.py 2014-09-08 10:08:15 +0000
@@ -76,9 +76,7 @@
# TODO: Items left to test
# PresentationDocument
# __init__
- # load_presentation
# presentation_deleted
- # get_file_name
# get_thumbnail_folder
# get_temp_folder
# check_thumbnails
@@ -109,11 +107,13 @@
patch('openlp.plugins.presentations.lib.presentationcontroller.check_directory_exists')
self.get_thumbnail_folder_patcher = \
patch('openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder')
+ self.os_patcher = patch('openlp.plugins.presentations.lib.presentationcontroller.os')
self._setup_patcher = \
patch('openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument._setup')
self.mock_check_directory_exists = self.check_directory_exists_patcher.start()
self.mock_get_thumbnail_folder = self.get_thumbnail_folder_patcher.start()
+ self.mock_os = self.os_patcher.start()
self.mock_setup = self._setup_patcher.start()
self.mock_controller = MagicMock()
@@ -126,6 +126,7 @@
"""
self.check_directory_exists_patcher.stop()
self.get_thumbnail_folder_patcher.stop()
+ self.os_patcher.stop()
self._setup_patcher.stop()
def initialise_presentation_document_test(self):
@@ -156,3 +157,34 @@
self.mock_check_directory_exists.assert_called_once_with('returned/path/')
self._setup_patcher.start()
+
+ def load_presentation_test(self):
+ """
+ Test the PresentationDocument load_presentation method.
+ """
+
+ # GIVEN: An instance of PresentationDocument
+ instance = PresentationDocument(self.mock_controller, 'Name')
+
+ # WHEN: Calling load_presentation()
+ result = instance.load_presentation()
+
+ # THEN: False should be returned
+ self.assertFalse(result, "PresentationDocument.load_presentation should return false.")
+
+ def get_file_name_test(self):
+ """
+ Test the get_file_name method.
+ """
+
+ # GIVEN: A mocked out os.path.split with specified return value, an instance of PresentationDocument and
+ # arbitary file_path
+ self.mock_os.path.split.return_value = ['directory', 'file.ext']
+ instance = PresentationDocument(self.mock_controller, 'Name')
+ instance.file_path = 'filepath'
+
+ # WHEN: Calling get_file_name
+ result = instance.get_file_name()
+
+ # THEN: The file name should have been returned
+ self.assertEqual(result, 'file.ext')
\ No newline at end of file
Follow ups