forked from openlp/openlp
parent
5ae5d8c07e
commit
9606b99976
@ -243,7 +243,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
Clean up the files created such as thumbnails
|
Clean up the files created such as thumbnails
|
||||||
|
|
||||||
:param openlp.core.common.path.Path file_path: File path of the presention to clean up after
|
:param openlp.core.common.path.Path file_path: File path of the presentation to clean up after
|
||||||
:param bool clean_for_update: Only clean thumbnails if update is needed
|
:param bool clean_for_update: Only clean thumbnails if update is needed
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
|
@ -139,7 +139,8 @@ class PresentationDocument(object):
|
|||||||
:return: The path to the thumbnail
|
:return: The path to the thumbnail
|
||||||
:rtype: openlp.core.common.path.Path
|
:rtype: openlp.core.common.path.Path
|
||||||
"""
|
"""
|
||||||
# TODO: If statement can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed
|
# TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in
|
||||||
|
# get_temp_folder and PresentationPluginapp_startup is removed
|
||||||
if Settings().value('presentations/thumbnail_scheme') == 'md5':
|
if Settings().value('presentations/thumbnail_scheme') == 'md5':
|
||||||
folder = md5_hash(bytes(self.file_path))
|
folder = md5_hash(bytes(self.file_path))
|
||||||
else:
|
else:
|
||||||
@ -153,7 +154,8 @@ class PresentationDocument(object):
|
|||||||
:return: The path to the temporary file folder
|
:return: The path to the temporary file folder
|
||||||
:rtype: openlp.core.common.path.Path
|
:rtype: openlp.core.common.path.Path
|
||||||
"""
|
"""
|
||||||
# TODO: If statement can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed
|
# TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in
|
||||||
|
# get_thumbnail_folder and PresentationPluginapp_startup is removed
|
||||||
if Settings().value('presentations/thumbnail_scheme') == 'md5':
|
if Settings().value('presentations/thumbnail_scheme') == 'md5':
|
||||||
folder = md5_hash(bytes(self.file_path))
|
folder = md5_hash(bytes(self.file_path))
|
||||||
else:
|
else:
|
||||||
|
@ -31,6 +31,7 @@ from PyQt5 import QtCore
|
|||||||
from openlp.core.api.http import register_endpoint
|
from openlp.core.api.http import register_endpoint
|
||||||
from openlp.core.common import extension_loader
|
from openlp.core.common import extension_loader
|
||||||
from openlp.core.common.i18n import translate
|
from openlp.core.common.i18n import translate
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon
|
from openlp.core.lib import Plugin, StringContent, build_icon
|
||||||
from openlp.plugins.presentations.endpoint import api_presentations_endpoint, presentations_endpoint
|
from openlp.plugins.presentations.endpoint import api_presentations_endpoint, presentations_endpoint
|
||||||
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
|
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
|
||||||
@ -136,6 +137,20 @@ class PresentationPlugin(Plugin):
|
|||||||
self.register_controllers(controller)
|
self.register_controllers(controller)
|
||||||
return bool(self.controllers)
|
return bool(self.controllers)
|
||||||
|
|
||||||
|
def app_startup(self):
|
||||||
|
"""
|
||||||
|
Perform tasks on application startup.
|
||||||
|
"""
|
||||||
|
# TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in
|
||||||
|
# PresentationDocument.get_thumbnail_folder and PresentationDocument.get_temp_folder is removed
|
||||||
|
super().app_startup()
|
||||||
|
files_from_config = Settings().value('presentations/presentations files')
|
||||||
|
for file in files_from_config:
|
||||||
|
self.media_item.clean_up_thumbnails(file, clean_for_update=True)
|
||||||
|
self.media_item.list_view.clear()
|
||||||
|
Settings().setValue('presentations/thumbnail_scheme', 'md5')
|
||||||
|
self.media_item.validate_and_load(files_from_config)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def about():
|
def about():
|
||||||
"""
|
"""
|
||||||
|
@ -133,3 +133,27 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: doc.presentation_deleted should have been called since the presentation file did not exists.
|
# THEN: doc.presentation_deleted should have been called since the presentation file did not exists.
|
||||||
mocked_doc.assert_has_calls([call.get_thumbnail_path(1, True), call.presentation_deleted()], True)
|
mocked_doc.assert_has_calls([call.get_thumbnail_path(1, True), call.presentation_deleted()], True)
|
||||||
|
|
||||||
|
@patch('openlp.plugins.presentations.lib.mediaitem.MediaManagerItem._setup')
|
||||||
|
@patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.setup_item')
|
||||||
|
@patch('openlp.plugins.presentations.lib.mediaitem.Settings')
|
||||||
|
def test_search(self, mocked_settings, *unreferenced_mocks):
|
||||||
|
"""
|
||||||
|
Test that the search method finds the correct results
|
||||||
|
"""
|
||||||
|
# GIVEN: A mocked Settings class which returns a list of Path objects,
|
||||||
|
# and an instance of the PresentationMediaItem
|
||||||
|
path_1 = Path('some_dir', 'Impress_file_1')
|
||||||
|
path_2 = Path('some_other_dir', 'impress_file_2')
|
||||||
|
path_3 = Path('another_dir', 'ppt_file')
|
||||||
|
mocked_returned_settings = MagicMock()
|
||||||
|
mocked_returned_settings.value.return_value = [path_1, path_2, path_3]
|
||||||
|
mocked_settings.return_value = mocked_returned_settings
|
||||||
|
media_item = PresentationMediaItem(None, MagicMock(), None)
|
||||||
|
media_item.settings_section = ''
|
||||||
|
|
||||||
|
# WHEN: Calling search
|
||||||
|
results = media_item.search('IMPRE', False)
|
||||||
|
|
||||||
|
# THEN: The first two results should have been returned
|
||||||
|
assert results == [[str(path_1), 'Impress_file_1'], [str(path_2), 'impress_file_2']]
|
||||||
|
Loading…
Reference in New Issue
Block a user