A few bug fixes

This commit is contained in:
Tomas Groth 2022-01-21 07:49:55 +00:00 committed by Tim Bentley
parent 2143d89d1d
commit bfce3db902
3 changed files with 10 additions and 4 deletions

View File

@ -62,7 +62,9 @@ class ServiceItemEditForm(QtWidgets.QDialog, Ui_ServiceItemEditDialog, RegistryP
# self.data is only true for images
self.item.slides = []
for item in self.item_list:
self.item.add_from_image(item['path'], item['title'])
thumb = item.get('thumbnail', None)
file_hash = item.get('file_hash', None)
self.item.add_from_image(item['path'], item['title'], thumb, file_hash)
return self.item
def load_data(self):

View File

@ -762,7 +762,11 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
"""
# If the file_path is a string, this method will fail. Typecase to Path
file_path = Path(file_path)
if not file_path.exists():
try:
if not file_path.exists():
return False
except OSError:
# if the filename, directory name, or volume label syntax is incorrect it can cause an exception
return False
service_data = None
self.application.set_busy_cursor()

View File

@ -84,8 +84,8 @@ def test_get_service_item(form):
assert item is form.item, 'The returned item should be form.item'
# FYI: list should be empty because it was cleared but never filled again due to the mock
assert item.slides == [], 'The list of slides should have been cleared'
assert item.add_from_image.call_args_list == [call('../slide1.jpg', 'slide1.jpg'),
call('../slide2.jpg', 'slide2.jpg')]
assert item.add_from_image.call_args_list == [call('../slide1.jpg', 'slide1.jpg', None, None),
call('../slide2.jpg', 'slide2.jpg', None, None)]
@patch('openlp.core.ui.serviceitemeditform.QtWidgets.QListWidgetItem')