Added a test.

This commit is contained in:
Tomas Groth 2016-02-06 21:33:27 +01:00
parent 17d6f13ac0
commit c75d0cee29
1 changed files with 24 additions and 0 deletions

View File

@ -26,6 +26,7 @@ from unittest import TestCase
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.plugins.presentations.lib.mediaitem import MessageListener, PresentationMediaItem from openlp.plugins.presentations.lib.mediaitem import MessageListener, PresentationMediaItem
from openlp.plugins.presentations.lib.messagelistener import Controller
from tests.functional import patch, MagicMock from tests.functional import patch, MagicMock
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -124,3 +125,26 @@ class TestMessageListener(TestCase, TestMixin):
# THEN: The handler should be set to None # THEN: The handler should be set to None
self.assertIsNone(ml.handler, 'The handler should be None') self.assertIsNone(ml.handler, 'The handler should be None')
class TestController(TestCase, TestMixin):
"""
Test the Presentation Controller.
"""
def add_handler_failure_test(self):
"""
Test that add_handler does set doc.slidenumber to 0 in case filed loading
"""
# GIVEN: A Controller, a mocked doc-controller
controller = Controller(True)
mocked_doc_controller = MagicMock()
mocked_doc = MagicMock()
mocked_doc.load_presentation.return_value = False
mocked_doc_controller.add_document.return_value = mocked_doc
# WHEN: calling add_handler that fails
controller.add_handler(mocked_doc_controller, MagicMock(), True, 0)
# THEN: slidenumber should be 0
self.assertEqual(controller.doc.slidenumber, 0, 'doc.slidenumber should be 0')