forked from openlp/openlp
Use patch decorator for test.
This commit is contained in:
parent
33a4e00002
commit
fe40cb6eec
@ -244,32 +244,32 @@ class TestServiceItem(TestCase):
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
|
||||
def add_from_command_for_a_presentation_thumb_test(self):
|
||||
@patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path')
|
||||
def add_from_command_for_a_presentation_thumb_test(self, mocked_get_section_data_path):
|
||||
"""
|
||||
Test the Service Item - adding a presentation, and updating the thumb path
|
||||
"""
|
||||
# GIVEN: A service item, a mocked icon and presentation data
|
||||
with patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path') as mocked_get_section_data_path:
|
||||
mocked_get_section_data_path.return_value = os.path.join('mocked', 'section', 'path')
|
||||
service_item = ServiceItem(None)
|
||||
service_item.has_original_files = False
|
||||
service_item.name = 'presentations'
|
||||
presentation_name = 'test.pptx'
|
||||
thumb = os.path.join('tmp', 'test', 'thumb.png')
|
||||
display_title = 'DisplayTitle'
|
||||
notes = 'Note1\nNote2\n'
|
||||
expected_thumb_path = os.path.join('mocked', 'section', 'path', 'thumbnails',
|
||||
md5_hash(os.path.join(TEST_PATH, presentation_name).encode('utf-8')),
|
||||
'thumb.png')
|
||||
frame = {'title': presentation_name, 'image': expected_thumb_path, 'path': TEST_PATH,
|
||||
'display_title': display_title, 'notes': notes}
|
||||
# GIVEN: A service item, a mocked AppLocation and presentation data
|
||||
mocked_get_section_data_path.return_value = os.path.join('mocked', 'section', 'path')
|
||||
service_item = ServiceItem(None)
|
||||
service_item.has_original_files = False
|
||||
service_item.name = 'presentations'
|
||||
presentation_name = 'test.pptx'
|
||||
thumb = os.path.join('tmp', 'test', 'thumb.png')
|
||||
display_title = 'DisplayTitle'
|
||||
notes = 'Note1\nNote2\n'
|
||||
expected_thumb_path = os.path.join('mocked', 'section', 'path', 'thumbnails',
|
||||
md5_hash(os.path.join(TEST_PATH, presentation_name).encode('utf-8')),
|
||||
'thumb.png')
|
||||
frame = {'title': presentation_name, 'image': expected_thumb_path, 'path': TEST_PATH,
|
||||
'display_title': display_title, 'notes': notes}
|
||||
|
||||
# WHEN: adding presentation to service_item
|
||||
service_item.add_from_command(TEST_PATH, presentation_name, thumb, display_title, notes)
|
||||
# WHEN: adding presentation to service_item
|
||||
service_item.add_from_command(TEST_PATH, presentation_name, thumb, display_title, notes)
|
||||
|
||||
# THEN: verify that it is setup as a Command and that the frame data matches
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
# THEN: verify that it is setup as a Command and that the frame data matches
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
|
||||
def service_item_load_optical_media_from_service_test(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user