~trb143/openlp/bug-1516171-24

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core_lib/test_serviceitem.py

  • Committer: Raoul Snyman
  • Author(s): Tomas Groth
  • Date: 2015-06-14 18:38:44 UTC
  • mfrom: (2543.1.14 bugfixes21)
  • Revision ID: raoul@snyman.info-20150614183844-wxfg3itu1zu9toiu
Fix path of presentation thumbnail when loading from service files. Fixes bug 1463703.
Fix PDF reader using wrong maindisplay size.
Fix log-traceback when trying to remove servicemanager files before eg. powerpoint has closed the files.
Improve network exception handling.
Fix timer that checks for presentation slide change, remove powerpoint event handler that did the same.
Hide the main impress window when loading a presentation, but make it visible for a moment when starting presentation. Fixes bug 1420356.
Improve the detection of powerpoints presentation window by only looking at the filename root.
Fix traceback when going live with presentation while blanked to desktop.
Set service_item.name to "images" for pdfs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from tests.functional import MagicMock, patch
29
29
from tests.utils import assert_length, convert_file_service_item
30
30
 
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
33
33
 
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')
246
246
 
 
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):
 
249
        """
 
250
        Test the Service Item - adding a presentation, and updating the thumb path
 
251
        """
 
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')),
 
263
                                           'thumb.png')
 
264
        frame = {'title': presentation_name, 'image': expected_thumb_path, 'path': TEST_PATH,
 
265
                 'display_title': display_title, 'notes': notes}
 
266
 
 
267
        # WHEN: adding presentation to service_item
 
268
        service_item.add_from_command(TEST_PATH, presentation_name, thumb, display_title, notes)
 
269
 
 
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')
 
273
 
247
274
    def service_item_load_optical_media_from_service_test(self):
248
275
        """
249
276
        Test the Service Item - load an optical media item