From 05be4e606c65f168807fe7e17fec06bdd86e584b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 5 Jun 2016 19:48:07 +0100 Subject: [PATCH] Fix up tests --- openlp/core/lib/remote/poll.py | 2 +- .../openlp_core_ui/test_mainwindow.py | 2 +- .../openlp_plugins/remotes/test_remotetab.py | 33 ------------------- .../openlp_plugins/remotes/test_router.py | 17 +++++----- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/openlp/core/lib/remote/poll.py b/openlp/core/lib/remote/poll.py index 73ed4c376..580d68f21 100644 --- a/openlp/core/lib/remote/poll.py +++ b/openlp/core/lib/remote/poll.py @@ -22,7 +22,7 @@ import json -from openlp.core.common import RegistryProperties, Settings, OpenLPMixin +from openlp.core.common import RegistryProperties, Settings class OpenLPPoll(RegistryProperties): diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index 8a8b2516c..93baa8da7 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -149,7 +149,7 @@ class TestMainWindow(TestCase, TestMixin): # WHEN: you check the started functions # THEN: the following registry functions should have been registered - self.assertEqual(len(self.registry.service_list), 6, 'The registry should have 6 services.') + self.assertEqual(len(self.registry.service_list), 7, 'The registry should have 7 services.') self.assertEqual(len(self.registry.functions_list), 17, 'The registry should have 17 functions') self.assertTrue('application' in self.registry.service_list, 'The application should have been registered.') self.assertTrue('main_window' in self.registry.service_list, 'The main_window should have been registered.') diff --git a/tests/functional/openlp_plugins/remotes/test_remotetab.py b/tests/functional/openlp_plugins/remotes/test_remotetab.py index 24375740f..4224671f1 100644 --- a/tests/functional/openlp_plugins/remotes/test_remotetab.py +++ b/tests/functional/openlp_plugins/remotes/test_remotetab.py @@ -37,8 +37,6 @@ from tests.helpers.testmixin import TestMixin __default_settings__ = { 'remotes/twelve hour': True, 'remotes/port': 4316, - 'remotes/https port': 4317, - 'remotes/https enabled': False, 'remotes/user id': 'openlp', 'remotes/password': 'password', 'remotes/authentication enabled': False, @@ -114,36 +112,5 @@ class TestRemoteTab(TestCase, TestMixin): self.form.set_urls() # THEN: the following screen values should be set self.assertEqual(self.form.address_edit.text(), ZERO_URL, 'The default URL should be set on the screen') - self.assertEqual(self.form.https_settings_group_box.isEnabled(), False, - 'The Https box should not be enabled') - self.assertEqual(self.form.https_settings_group_box.isChecked(), False, - 'The Https checked box should note be Checked') self.assertEqual(self.form.user_login_group_box.isChecked(), False, 'The authentication box should not be enabled') - - def set_certificate_urls_test(self): - """ - Test the set_urls function with certificate available - """ - # GIVEN: A mocked location - with patch('openlp.core.common.Settings') as mocked_class, \ - patch('openlp.core.common.applocation.AppLocation.get_directory') as mocked_get_directory, \ - patch('openlp.core.common.check_directory_exists') as mocked_check_directory_exists, \ - patch('openlp.core.common.applocation.os') as mocked_os: - # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory() - mocked_settings = mocked_class.return_value - mocked_settings.contains.return_value = False - mocked_get_directory.return_value = TEST_PATH - mocked_check_directory_exists.return_value = True - mocked_os.path.normpath.return_value = TEST_PATH - - # WHEN: when the set_urls is called having reloaded the form. - self.form.load() - self.form.set_urls() - # THEN: the following screen values should be set - self.assertEqual(self.form.http_settings_group_box.isEnabled(), True, - 'The Http group box should be enabled') - self.assertEqual(self.form.https_settings_group_box.isChecked(), False, - 'The Https checked box should be Checked') - self.assertEqual(self.form.https_settings_group_box.isEnabled(), True, - 'The Https box should be enabled') diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index d1715ab8d..d60d80f87 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -28,6 +28,7 @@ from unittest import TestCase from openlp.core.common import Settings, Registry from openlp.core.ui import ServiceManager +from openlp.core.lib.remote import OpenLPPoll from openlp.plugins.remotes.lib.httpserver import HttpRouter from tests.functional import MagicMock, patch, mock_open from tests.helpers.testmixin import TestMixin @@ -35,8 +36,6 @@ from tests.helpers.testmixin import TestMixin __default_settings__ = { 'remotes/twelve hour': True, 'remotes/port': 4316, - 'remotes/https port': 4317, - 'remotes/https enabled': False, 'remotes/user id': 'openlp', 'remotes/password': 'password', 'remotes/authentication enabled': False, @@ -74,6 +73,8 @@ class TestRouter(TestCase, TestMixin): # GIVEN: A default configuration Settings().setValue('remotes/user id', 'openlp') Settings().setValue('remotes/password', 'password') + poll = MagicMock() + Registry().register('OpenLPPoll', poll) # WHEN: called with the defined userid router = HttpRouter() @@ -157,15 +158,13 @@ class TestRouter(TestCase, TestMixin): """ # GIVEN: a defined router with two slides Registry.create() - 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 + live_controller = MagicMock() + Registry().register('live_controller', live_controller) + poll = OpenLPPoll() + live_controller.slide_count = 2 # WHEN: main poll called - results = router.main_poll() + results = poll.main_poll() # THEN: the correct response should be returned self.assertEqual(results.decode('utf-8'), '{"results": {"slide_count": 2}}',