From 518d391e458ab22ad7e7c37588702d9bbe50fd2d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 27 Apr 2014 16:38:48 +0100 Subject: [PATCH 1/5] Fix trunk --- openlp/plugins/songs/lib/upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index adb7d8af5..546343900 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -39,7 +39,7 @@ from sqlalchemy.sql.expression import func, false, null, text from openlp.core.lib.db import get_upgrade_op log = logging.getLogger(__name__) -__version__ = 3 +__version__ = 4 def upgrade_1(session, metadata): From f21d3cfa838335deccc20355bb9d512038c9cb8e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 3 May 2014 20:32:19 +0100 Subject: [PATCH 2/5] fix tests --- tests/functional/openlp_core_lib/test_image_manager.py | 2 +- tests/functional/openlp_core_ui/test_media.py | 2 +- tests/interfaces/openlp_core_common/test_historycombobox.py | 2 +- tests/interfaces/openlp_core_ui/test_shortcutlistform.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index 37b6d6fdd..072978993 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -171,4 +171,4 @@ class TestImageManager(TestCase, TestMixin): self.lock.release() # The sleep time is adjusted in the test case. time.sleep(self.sleep_time) - return '' \ No newline at end of file + return '' diff --git a/tests/functional/openlp_core_ui/test_media.py b/tests/functional/openlp_core_ui/test_media.py index d59690949..4c6fa7f86 100644 --- a/tests/functional/openlp_core_ui/test_media.py +++ b/tests/functional/openlp_core_ui/test_media.py @@ -125,4 +125,4 @@ class TestMedia(TestCase, TestMixin): # THEN: the used_players should be an empty list, and the overridden player should be an empty string self.assertEqual(['vlc', 'webkit', 'phonon'], used_players, 'Used players should be correct') - self.assertEqual('vlc,webkit,phonon', overridden_player, 'Overridden player should be a string of players') \ No newline at end of file + self.assertEqual('vlc,webkit,phonon', overridden_player, 'Overridden player should be a string of players') diff --git a/tests/interfaces/openlp_core_common/test_historycombobox.py b/tests/interfaces/openlp_core_common/test_historycombobox.py index 00a63f15f..c0131e46c 100644 --- a/tests/interfaces/openlp_core_common/test_historycombobox.py +++ b/tests/interfaces/openlp_core_common/test_historycombobox.py @@ -62,4 +62,4 @@ class TestHistoryComboBox(TestCase, TestMixin): self.combo.addItem('test2') # THEN: The list of items should contain both strings. - self.assertEqual(self.combo.getItems(), ['test1', 'test2']) \ No newline at end of file + self.assertEqual(self.combo.getItems(), ['test1', 'test2']) diff --git a/tests/interfaces/openlp_core_ui/test_shortcutlistform.py b/tests/interfaces/openlp_core_ui/test_shortcutlistform.py index 472bce03f..29c365194 100644 --- a/tests/interfaces/openlp_core_ui/test_shortcutlistform.py +++ b/tests/interfaces/openlp_core_ui/test_shortcutlistform.py @@ -75,4 +75,4 @@ class TestShortcutform(TestCase, TestMixin): # THEN: The button should be changed. self.assertEqual(button.text(), text, "The text should match.") mocked_check_method.assert_called_once_with(True) - self.assertEqual(button.isEnabled(), enabled, "The button should be disabled.") \ No newline at end of file + self.assertEqual(button.isEnabled(), enabled, "The button should be disabled.") From d6d3cd1394ca7cce172c0b6ca762fe38fff9de4d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 3 May 2014 21:00:17 +0100 Subject: [PATCH 3/5] Fix call path --- openlp/plugins/media/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 92426334a..0780b175d 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -229,7 +229,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): self.service_path = os.path.join(AppLocation.get_section_data_path(self.settings_section), 'thumbnails') check_directory_exists(self.service_path) self.load_list(Settings().value(self.settings_section + '/media files')) - self.populate_display_types() + self.rebuild_players() def rebuild_players(self): """ From 1e6f00c2ebd19f92705a7d0dd6435fe20c02bd36 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 7 May 2014 17:05:27 +0100 Subject: [PATCH 4/5] Add test --- .../openlp_core_ui/test_slidecontroller.py | 2 +- .../openlp_plugins/remotes/test_router.py | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_slidecontroller.py b/tests/functional/openlp_core_ui/test_slidecontroller.py index 56d87c511..104c83750 100644 --- a/tests/functional/openlp_core_ui/test_slidecontroller.py +++ b/tests/functional/openlp_core_ui/test_slidecontroller.py @@ -33,7 +33,7 @@ from unittest import TestCase from openlp.core.ui import SlideController -from tests.interfaces import MagicMock, patch +from tests.interfaces import MagicMock class TestSlideController(TestCase): diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 9e13a448b..1388e6104 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -32,7 +32,7 @@ This module contains tests for the lib submodule of the Remotes plugin. import os from unittest import TestCase -from openlp.core.common import Settings +from openlp.core.common import Settings, Registry from openlp.plugins.remotes.lib.httpserver import HttpRouter from tests.functional import MagicMock, patch, mock_open from tests.helpers.testmixin import TestMixin @@ -92,15 +92,15 @@ class TestRouter(TestCase, TestMixin): Test the router control functionality """ # GIVEN: A testing set of Routes - router = HttpRouter() + #router = HttpRouter() mocked_function = MagicMock() test_route = [ (r'^/stage/api/poll$', {'function': mocked_function, 'secure': False}), ] - router.routes = test_route + self.router.routes = test_route # WHEN: called with a poll route - function, args = router.process_http_request('/stage/api/poll', None) + function, args = self.router.process_http_request('/stage/api/poll', None) # THEN: the function should have been called only once self.assertEqual(mocked_function, function['function'], 'The mocked function should match defined value.') @@ -126,6 +126,25 @@ class TestRouter(TestCase, TestMixin): # THEN: all types should match self.assertEqual(content_type, header[1], 'Mismatch of content type') + def main_poll_test(self): + """ + Test the main poll logic + """ + # GIVEN: a defined router with two slides + Registry().register('live_controller', MagicMock) + router = HttpRouter() + router.send_response = MagicMock() + router.send_header = MagicMock() + router.end_headers = MagicMock() + router.live_controller.slide_count = 2 + + # WHEN: main poll called + results = router.main_poll() + + # THEN: the correct response should be returned + self.assertEqual(results.decode('utf-8'), '{"results": {"slide_count": 2}}', + 'The resulting json strings should match') + def serve_file_without_params_test(self): """ Test the serve_file method without params From c6d6be30c6b90388304eb8f1ca0af83ea0442f3c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 7 May 2014 21:38:34 +0100 Subject: [PATCH 5/5] fix --- tests/functional/openlp_plugins/remotes/test_router.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 1388e6104..037169b88 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -92,7 +92,6 @@ class TestRouter(TestCase, TestMixin): Test the router control functionality """ # GIVEN: A testing set of Routes - #router = HttpRouter() mocked_function = MagicMock() test_route = [ (r'^/stage/api/poll$', {'function': mocked_function, 'secure': False}),