28
28
from tests.functional import MagicMock, patch
29
29
from tests.utils import assert_length, convert_file_service_item
31
from openlp.core.common import Registry
31
from openlp.core.common import Registry, md5_hash
32
32
from openlp.core.lib import ItemCapabilities, ServiceItem, ServiceItemType
34
34
VERSE = 'The Lord said to {r}Noah{/r}: \n'\
244
244
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
245
245
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
247
@patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path')
248
def add_from_command_for_a_presentation_thumb_test(self, mocked_get_section_data_path):
250
Test the Service Item - adding a presentation, and updating the thumb path
252
# GIVEN: A service item, a mocked AppLocation and presentation data
253
mocked_get_section_data_path.return_value = os.path.join('mocked', 'section', 'path')
254
service_item = ServiceItem(None)
255
service_item.has_original_files = False
256
service_item.name = 'presentations'
257
presentation_name = 'test.pptx'
258
thumb = os.path.join('tmp', 'test', 'thumb.png')
259
display_title = 'DisplayTitle'
260
notes = 'Note1\nNote2\n'
261
expected_thumb_path = os.path.join('mocked', 'section', 'path', 'thumbnails',
262
md5_hash(os.path.join(TEST_PATH, presentation_name).encode('utf-8')),
264
frame = {'title': presentation_name, 'image': expected_thumb_path, 'path': TEST_PATH,
265
'display_title': display_title, 'notes': notes}
267
# WHEN: adding presentation to service_item
268
service_item.add_from_command(TEST_PATH, presentation_name, thumb, display_title, notes)
270
# THEN: verify that it is setup as a Command and that the frame data matches
271
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
272
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
247
274
def service_item_load_optical_media_from_service_test(self):
249
276
Test the Service Item - load an optical media item