mirror of https://gitlab.com/openlp/openlp.git
Skip missing thumbnails when loading a service
This commit is contained in:
parent
6a67c2d89f
commit
f1fe916781
|
@ -522,8 +522,9 @@ class ServiceItem(RegistryProperties):
|
|||
if text_image['image']:
|
||||
thumbnail = AppLocation.get_data_path() / text_image['image']
|
||||
# copy thumbnail from servicemanager path
|
||||
copy(path / 'thumbnails' / os.path.basename(text_image['image']),
|
||||
AppLocation.get_section_data_path(self.name) / 'thumbnails')
|
||||
if thumbnail.exists():
|
||||
copy(path / 'thumbnails' / os.path.basename(text_image['image']),
|
||||
AppLocation.get_section_data_path(self.name) / 'thumbnails')
|
||||
else:
|
||||
text = text_image
|
||||
org_file_path = path / text
|
||||
|
|
|
@ -35,6 +35,7 @@ from openlp.core.common.registry import Registry
|
|||
from openlp.core.lib.formattingtags import FormattingTags
|
||||
from openlp.core.lib.serviceitem import ItemCapabilities, ServiceItem
|
||||
from openlp.core.lib.theme import TransitionSpeed
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from tests.utils import convert_file_service_item
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
|
||||
|
@ -965,3 +966,19 @@ def test_to_dict_presentation_item(mocked_image_uri, mocked_get_data_path, state
|
|||
'data': {}
|
||||
}
|
||||
assert result == expected_dict
|
||||
|
||||
|
||||
@pytest.mark.parametrize('plugin_name,icon', [('songs', 'music'), ('bibles', 'bible'),
|
||||
('presentations', 'presentation'), ('images', 'picture'),
|
||||
('media', 'video')])
|
||||
def test_add_icon(registry, plugin_name, icon):
|
||||
"""Test that adding an icon works according to the plugin name"""
|
||||
# GIVEN: A service item
|
||||
service_item = ServiceItem()
|
||||
service_item.name = plugin_name
|
||||
|
||||
# WHEN: add_icon() is called
|
||||
service_item.add_icon()
|
||||
|
||||
# THEN: The icon should be correct
|
||||
assert service_item.icon.name() == getattr(UiIcons(), icon).name()
|
||||
|
|
Loading…
Reference in New Issue