forked from openlp/openlp
Fix up presentation tests
This commit is contained in:
parent
43f156d9fe
commit
1301b4cfa3
@ -93,11 +93,7 @@ class TestMediaItem(TestCase):
|
|||||||
self.media_item.build_file_mask_string()
|
self.media_item.build_file_mask_string()
|
||||||
|
|
||||||
# THEN: The file mask should be generated correctly
|
# THEN: The file mask should be generated correctly
|
||||||
self.assertIn('*.odp', self.media_item.on_new_file_masks,
|
self.assertIn('*.odp', self.media_item.on_new_file_masks, 'The file mask should contain the odp extension')
|
||||||
'The file mask should contain the odp extension')
|
self.assertIn('*.ppt', self.media_item.on_new_file_masks, 'The file mask should contain the ppt extension')
|
||||||
self.assertIn('*.ppt', self.media_item.on_new_file_masks,
|
self.assertIn('*.pdf', self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension')
|
||||||
'The file mask should contain the ppt extension')
|
self.assertIn('*.xps', self.media_item.on_new_file_masks, 'The file mask should contain the xps extension')
|
||||||
self.assertIn('*.pdf', self.media_item.on_new_file_masks,
|
|
||||||
'The file mask should contain the pdf extension')
|
|
||||||
self.assertIn('*.xps', self.media_item.on_new_file_masks,
|
|
||||||
'The file mask should contain the xps extension')
|
|
||||||
|
@ -77,7 +77,7 @@ class TestPdfController(TestCase):
|
|||||||
|
|
||||||
def constructor_test(self):
|
def constructor_test(self):
|
||||||
"""
|
"""
|
||||||
Test the Constructor
|
Test the Constructor from the PdfController
|
||||||
"""
|
"""
|
||||||
# GIVEN: No presentation controller
|
# GIVEN: No presentation controller
|
||||||
controller = None
|
controller = None
|
||||||
@ -90,7 +90,7 @@ class TestPdfController(TestCase):
|
|||||||
|
|
||||||
def load_pdf_test(self):
|
def load_pdf_test(self):
|
||||||
"""
|
"""
|
||||||
Test loading of a Pdf
|
Test loading of a Pdf using the PdfController
|
||||||
"""
|
"""
|
||||||
# GIVEN: A Pdf-file
|
# GIVEN: A Pdf-file
|
||||||
test_file = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'pdf_test1.pdf')
|
test_file = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'pdf_test1.pdf')
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"""
|
"""
|
||||||
This module contains tests for the pptviewcontroller module of the Presentations plugin.
|
This module contains tests for the pptviewcontroller module of the Presentations plugin.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from tests.functional import MagicMock, patch
|
from tests.functional import MagicMock, patch
|
||||||
@ -43,6 +43,7 @@ from openlp.plugins.presentations.lib.pptviewcontroller import PptviewDocument
|
|||||||
# start_process(self)
|
# start_process(self)
|
||||||
# kill
|
# kill
|
||||||
|
|
||||||
|
|
||||||
class TestPptviewDocument(TestCase):
|
class TestPptviewDocument(TestCase):
|
||||||
"""
|
"""
|
||||||
Test the PptviewDocument Class
|
Test the PptviewDocument Class
|
||||||
@ -78,8 +79,8 @@ class TestPptviewDocument(TestCase):
|
|||||||
'openlp.plugins.presentations.lib.pptviewcontroller.PresentationDocument.get_temp_folder')
|
'openlp.plugins.presentations.lib.pptviewcontroller.PresentationDocument.get_temp_folder')
|
||||||
self.presentation_document_setup_patcher = patch(
|
self.presentation_document_setup_patcher = patch(
|
||||||
'openlp.plugins.presentations.lib.pptviewcontroller.PresentationDocument._setup')
|
'openlp.plugins.presentations.lib.pptviewcontroller.PresentationDocument._setup')
|
||||||
self.rect_patcher = patch('openlp.plugins.presentations.lib.pptviewcontroller.RECT')
|
|
||||||
self.screen_list_patcher = patch('openlp.plugins.presentations.lib.pptviewcontroller.ScreenList')
|
self.screen_list_patcher = patch('openlp.plugins.presentations.lib.pptviewcontroller.ScreenList')
|
||||||
|
self.rect_patcher = MagicMock()
|
||||||
|
|
||||||
self.mock_os = self.os_patcher.start()
|
self.mock_os = self.os_patcher.start()
|
||||||
self.mock_pptview_document_create_thumbnails = self.pptview_document_create_thumbnails_patcher.start()
|
self.mock_pptview_document_create_thumbnails = self.pptview_document_create_thumbnails_patcher.start()
|
||||||
@ -118,12 +119,14 @@ class TestPptviewDocument(TestCase):
|
|||||||
self.mock_controller.process.OpenPPT.return_value = 0
|
self.mock_controller.process.OpenPPT.return_value = 0
|
||||||
instance = PptviewDocument(self.mock_controller, self.mock_presentation)
|
instance = PptviewDocument(self.mock_controller, self.mock_presentation)
|
||||||
instance.filepath = 'test\path.ppt'
|
instance.filepath = 'test\path.ppt'
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
result = instance.load_presentation()
|
result = instance.load_presentation()
|
||||||
|
|
||||||
# THEN: PptviewDocument.load_presentation should return True
|
# THEN: PptviewDocument.load_presentation should return True
|
||||||
self.assertTrue(result)
|
self.assertTrue(result)
|
||||||
|
|
||||||
def load_presentation_unsuccesfull_test(self):
|
def load_presentation_un_succesfull_test(self):
|
||||||
"""
|
"""
|
||||||
Test the PptviewDocument.load_presentation() method when the temporary directory does not exist and the PPT is
|
Test the PptviewDocument.load_presentation() method when the temporary directory does not exist and the PPT is
|
||||||
not successfully opened
|
not successfully opened
|
||||||
@ -136,6 +139,7 @@ class TestPptviewDocument(TestCase):
|
|||||||
self.mock_controller.process.OpenPPT.return_value = -1
|
self.mock_controller.process.OpenPPT.return_value = -1
|
||||||
instance = PptviewDocument(self.mock_controller, self.mock_presentation)
|
instance = PptviewDocument(self.mock_controller, self.mock_presentation)
|
||||||
instance.filepath = 'test\path.ppt'
|
instance.filepath = 'test\path.ppt'
|
||||||
|
if os.name == 'nt':
|
||||||
result = instance.load_presentation()
|
result = instance.load_presentation()
|
||||||
|
|
||||||
# THEN: The temporary directory should be created and PptviewDocument.load_presentation should return False
|
# THEN: The temporary directory should be created and PptviewDocument.load_presentation should return False
|
||||||
|
@ -34,6 +34,7 @@ from unittest import TestCase
|
|||||||
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument
|
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument
|
||||||
from tests.functional import MagicMock, patch
|
from tests.functional import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestPresentationController(TestCase):
|
class TestPresentationController(TestCase):
|
||||||
"""
|
"""
|
||||||
Test the PresentationController.
|
Test the PresentationController.
|
||||||
@ -65,6 +66,7 @@ class TestPresentationController(TestCase):
|
|||||||
self.assertEqual('PresentationController', controller.name,
|
self.assertEqual('PresentationController', controller.name,
|
||||||
'The name of the presentation controller should be correct')
|
'The name of the presentation controller should be correct')
|
||||||
|
|
||||||
|
|
||||||
class TestPresentationDocument(TestCase):
|
class TestPresentationDocument(TestCase):
|
||||||
"""
|
"""
|
||||||
Test the PresentationDocument Class
|
Test the PresentationDocument Class
|
||||||
@ -101,12 +103,12 @@ class TestPresentationDocument(TestCase):
|
|||||||
"""
|
"""
|
||||||
Set up the patches and mocks need for all tests.
|
Set up the patches and mocks need for all tests.
|
||||||
"""
|
"""
|
||||||
self.check_directory_exists_patcher = patch(
|
self.check_directory_exists_patcher = \
|
||||||
'openlp.plugins.presentations.lib.presentationcontroller.check_directory_exists')
|
patch('openlp.plugins.presentations.lib.presentationcontroller.check_directory_exists')
|
||||||
self.get_thumbnail_folder_patcher = patch(
|
self.get_thumbnail_folder_patcher = \
|
||||||
'openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder')
|
patch('openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder')
|
||||||
self._setup_patcher = patch(
|
self._setup_patcher = \
|
||||||
'openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument._setup')
|
patch('openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument._setup')
|
||||||
|
|
||||||
self.mock_check_directory_exists = self.check_directory_exists_patcher.start()
|
self.mock_check_directory_exists = self.check_directory_exists_patcher.start()
|
||||||
self.mock_get_thumbnail_folder = self.get_thumbnail_folder_patcher.start()
|
self.mock_get_thumbnail_folder = self.get_thumbnail_folder_patcher.start()
|
||||||
@ -124,29 +126,29 @@ class TestPresentationDocument(TestCase):
|
|||||||
self.get_thumbnail_folder_patcher.stop()
|
self.get_thumbnail_folder_patcher.stop()
|
||||||
self._setup_patcher.stop()
|
self._setup_patcher.stop()
|
||||||
|
|
||||||
def initalise_presentation_document_test(self):
|
def initialise_presentation_document_test(self):
|
||||||
"""
|
"""
|
||||||
Test the PresentationDocument __init__ method when initalising the PresentationDocument Class
|
Test the PresentationDocument __init__ method when initialising the PresentationDocument Class
|
||||||
"""
|
"""
|
||||||
# GIVEN: A reset mock_setup and mocked controller
|
# GIVEN: A reset mock_setup and mocked controller
|
||||||
self.mock_setup.reset()
|
self.mock_setup.reset()
|
||||||
|
|
||||||
# WHEN: Creating an instance of PresentationDocument
|
# WHEN: Creating an instance of PresentationDocument
|
||||||
instance = PresentationDocument(self.mock_controller, 'Name')
|
PresentationDocument(self.mock_controller, 'Name')
|
||||||
|
|
||||||
# THEN: PresentationDocument.__init__ should have been called with the correct arguments
|
# THEN: PresentationDocument.__init__ should have been called with the correct arguments
|
||||||
self.mock_setup.assert_called_once_with('Name')
|
self.mock_setup.assert_called_once_with('Name')
|
||||||
|
|
||||||
def presentation_document_setup_test(self):
|
def presentation_document_setup_test(self):
|
||||||
"""
|
"""
|
||||||
Test the PresentationDocument _setup method when initalising the PresentationDocument Class
|
Test the PresentationDocument _setup method when initialising the PresentationDocument Class
|
||||||
"""
|
"""
|
||||||
self._setup_patcher.stop()
|
self._setup_patcher.stop()
|
||||||
|
|
||||||
# GIVEN: A mocked controller, patched check_directory_exists_patcher and patched get_thumbnail_folder method
|
# GIVEN: A mocked controller, patched check_directory_exists_patcher and patched get_thumbnail_folder method
|
||||||
|
|
||||||
# WHEN: Creating an instance of PresentationDocument
|
# WHEN: Creating an instance of PresentationDocument
|
||||||
instance = PresentationDocument(self.mock_controller, 'Name')
|
PresentationDocument(self.mock_controller, 'Name')
|
||||||
|
|
||||||
# THEN: check_directory_exists should have been called with the correct arguments
|
# THEN: check_directory_exists should have been called with the correct arguments
|
||||||
self.mock_check_directory_exists.assert_called_once_with('returned/path/')
|
self.mock_check_directory_exists.assert_called_once_with('returned/path/')
|
||||||
|
Loading…
Reference in New Issue
Block a user