mirror of https://gitlab.com/openlp/openlp.git
Fix #1700 by typecasting the calls to Paths
This commit is contained in:
parent
a58a403d06
commit
e1bd70284f
|
@ -466,8 +466,9 @@ class ServiceItem(RegistryProperties):
|
|||
else:
|
||||
for slide in self.slides:
|
||||
# When saving a service that originated from openlp 2.4 thumbnail might not be available
|
||||
# Also, sometimes this is not a Path object, but a string.
|
||||
if 'thumbnail' in slide:
|
||||
image_path = slide['thumbnail'].relative_to(AppLocation().get_data_path())
|
||||
image_path = Path(slide['thumbnail']).relative_to(AppLocation().get_data_path())
|
||||
else:
|
||||
# Check if (by chance) the thumbnails for this image is available on this machine
|
||||
test_thumb = AppLocation.get_section_data_path(self.name) / 'thumbnails' / stored_filename
|
||||
|
@ -483,7 +484,8 @@ class ServiceItem(RegistryProperties):
|
|||
elif lite_save:
|
||||
image = slide['image']
|
||||
else:
|
||||
image = slide['image'].relative_to(AppLocation().get_data_path())
|
||||
# Sometimss this is not a Path object, so typecast it
|
||||
image = Path(slide['image']).relative_to(AppLocation().get_data_path())
|
||||
service_data.append({'title': slide['title'], 'image': image, 'path': slide['path'],
|
||||
'display_title': slide['display_title'], 'notes': slide['notes']})
|
||||
return {'header': service_header, 'data': service_data}
|
||||
|
|
|
@ -1150,3 +1150,26 @@ def test_add_icon(registry, plugin_name, icon):
|
|||
|
||||
# THEN: The icon should be correct
|
||||
assert service_item.icon.name() == getattr(UiIcons(), icon).name()
|
||||
|
||||
|
||||
def test_get_service_repr_song(registry: Registry):
|
||||
"""Test the get_service_repr() method with a song"""
|
||||
# GIVEN: A service item
|
||||
registry.register('renderer', MagicMock())
|
||||
service_item = ServiceItem()
|
||||
service_item.name = 'songs'
|
||||
service_item.theme = 'Default'
|
||||
service_item.title = 'Test Song'
|
||||
service_item.add_from_text('This is the first slide')
|
||||
service_item.add_from_text('This is the second slide')
|
||||
service_item._create_slides()
|
||||
service_item.add_icon()
|
||||
|
||||
# WHEN: get_service_repr() is called
|
||||
rep = service_item.get_service_repr(False)
|
||||
|
||||
# THEN: The correct repr should have been made
|
||||
assert rep['header'].get('name') == 'songs'
|
||||
assert rep['header'].get('plugin') == 'songs'
|
||||
assert rep['header'].get('theme') == 'Default'
|
||||
assert rep['header'].get('title') == 'Test Song'
|
||||
|
|
Loading…
Reference in New Issue