def test_add_from_command_for_a_presentation_thumb( self, mocked_get_section_data_path, mocked_image_manager): """ Test the Service Item - adding a presentation, updating the thumb path & adding the thumb to image_manager """ # GIVEN: A service item, a mocked AppLocation and presentation data mocked_get_section_data_path.return_value = Path( 'mocked') / 'section' / 'path' service_item = ServiceItem(None) service_item.add_capability(ItemCapabilities.HasThumbnails) service_item.has_original_files = False service_item.name = 'presentations' presentation_name = 'test.pptx' thumb = Path('tmp') / 'test' / 'thumb.png' display_title = 'DisplayTitle' notes = 'Note1\nNote2\n' expected_thumb_path = Path('mocked') / 'section' / 'path' / 'thumbnails' / \ md5_hash(str(TEST_PATH / presentation_name).encode('utf8')) / 'thumb.png' frame = { 'title': presentation_name, 'image': str(expected_thumb_path), 'path': str(TEST_PATH), 'display_title': display_title, 'notes': notes, 'thumbnail': str(expected_thumb_path) } # WHEN: adding presentation to service_item service_item.add_from_command(str(TEST_PATH), presentation_name, thumb, display_title, notes) # THEN: verify that it is setup as a Command and that the frame data matches assert service_item.service_item_type == ServiceItemType.Command, 'It should be a Command' assert service_item.get_frames()[0] == frame, 'Frames should match'
def test_add_from_command_for_a_presentation(self): """ Test the Service Item - adding a presentation """ # GIVEN: A service item, a mocked icon and presentation data service_item = ServiceItem(None) presentation_name = 'test.pptx' image = MagicMock() display_title = 'DisplayTitle' notes = 'Note1\nNote2\n' frame = { 'title': presentation_name, 'image': image, 'path': TEST_PATH, 'display_title': display_title, 'notes': notes, 'thumbnail': image } # WHEN: adding presentation to service_item service_item.add_from_command(TEST_PATH, presentation_name, image, display_title, notes) # THEN: verify that it is setup as a Command and that the frame data matches assert service_item.service_item_type == ServiceItemType.Command, 'It should be a Command' assert service_item.get_frames()[0] == frame, 'Frames should match'
def test_add_from_command_without_display_title_and_notes(self): """ Test the Service Item - add from command, but not presentation """ # GIVEN: A new service item, a mocked icon and image data service_item = ServiceItem(None) image_name = 'test.img' image = MagicMock() frame = { 'title': image_name, 'image': image, 'path': TEST_PATH, 'display_title': None, 'notes': None, 'thumbnail': image } # WHEN: adding image to service_item service_item.add_from_command(TEST_PATH, image_name, image) # THEN: verify that it is setup as a Command and that the frame data matches assert service_item.service_item_type == ServiceItemType.Command, 'It should be a Command' assert service_item.get_frames()[0] == frame, 'Frames should match'