diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index b951ff038..4dc8d595a 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -288,4 +288,4 @@ def get_uno_instance(resolver, connection_type='pipe'): if connection_type == 'pipe': return resolver.resolve('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext') else: - return resolver.resolve('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') \ No newline at end of file + return resolver.resolve('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') diff --git a/tests/functional/openlp_core_common/test_init.py b/tests/functional/openlp_core_common/test_init.py index 1df0bcedc..2a8a3215d 100644 --- a/tests/functional/openlp_core_common/test_init.py +++ b/tests/functional/openlp_core_common/test_init.py @@ -24,7 +24,7 @@ Functional tests to test the AppLocation class and related methods. """ from unittest import TestCase -from openlp.core.common import add_actions +from openlp.core.common import add_actions, get_uno_instance from tests.functional import MagicMock @@ -92,3 +92,29 @@ class TestInit(TestCase): # THEN: The addSeparator method is called, and the addAction method is called mocked_target.addSeparator.assert_called_with() mocked_target.addAction.assert_called_with('action') + + def get_uno_instance_pipe_test(self): + """ + Test that when the UNO connection type is "pipe" the resolver is given the "pipe" URI + """ + # GIVEN: A mock resolver object and UNO_CONNECTION_TYPE is "pipe" + mock_resolver = MagicMock() + + # WHEN: get_uno_instance() is called + get_uno_instance(mock_resolver) + + # THEN: the resolve method is called with the correct argument + mock_resolver.resolve.assert_called_with('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext') + + def get_uno_instance_socket_test(self): + """ + Test that when the UNO connection type is other than "pipe" the resolver is given the "socket" URI + """ + # GIVEN: A mock resolver object and UNO_CONNECTION_TYPE is "socket" + mock_resolver = MagicMock() + + # WHEN: get_uno_instance() is called + get_uno_instance(mock_resolver, 'socket') + + # THEN: the resolve method is called with the correct argument + mock_resolver.resolve.assert_called_with('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') diff --git a/tests/functional/openlp_core_utils/test_utils.py b/tests/functional/openlp_core_utils/test_utils.py index 05941431f..0886a3997 100644 --- a/tests/functional/openlp_core_utils/test_utils.py +++ b/tests/functional/openlp_core_utils/test_utils.py @@ -27,7 +27,6 @@ from unittest import TestCase from openlp.core.utils import clean_filename, delete_file, get_filesystem_encoding, \ split_filename, _get_user_agent, get_web_page -from openlp.core.common import get_uno_instance from tests.functional import MagicMock, patch @@ -180,32 +179,6 @@ class TestUtils(TestCase): self.assertEqual(mocked_log.exception.call_count, 1) self.assertFalse(result, 'delete_file should return False when os.remove raises an OSError') - def get_uno_instance_pipe_test(self): - """ - Test that when the UNO connection type is "pipe" the resolver is given the "pipe" URI - """ - # GIVEN: A mock resolver object and UNO_CONNECTION_TYPE is "pipe" - mock_resolver = MagicMock() - - # WHEN: get_uno_instance() is called - get_uno_instance(mock_resolver) - - # THEN: the resolve method is called with the correct argument - mock_resolver.resolve.assert_called_with('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext') - - def get_uno_instance_socket_test(self): - """ - Test that when the UNO connection type is other than "pipe" the resolver is given the "socket" URI - """ - # GIVEN: A mock resolver object and UNO_CONNECTION_TYPE is "socket" - mock_resolver = MagicMock() - - # WHEN: get_uno_instance() is called - get_uno_instance(mock_resolver, 'socket') - - # THEN: the resolve method is called with the correct argument - mock_resolver.resolve.assert_called_with('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') - def get_user_agent_linux_test(self): """ Test that getting a user agent on Linux returns a user agent suitable for Linux @@ -287,7 +260,7 @@ class TestUtils(TestCase): with patch('openlp.core.utils.urllib.request.Request') as MockRequest, \ patch('openlp.core.utils.urllib.request.urlopen') as mock_urlopen, \ patch('openlp.core.utils._get_user_agent') as mock_get_user_agent, \ - patch('openlp.core.utils.Registry') as MockRegistry: + patch('openlp.core.common.Registry') as MockRegistry: # GIVEN: Mocked out objects and a fake URL mocked_request_object = MagicMock() MockRequest.return_value = mocked_request_object @@ -374,7 +347,7 @@ class TestUtils(TestCase): with patch('openlp.core.utils.urllib.request.Request') as MockRequest, \ patch('openlp.core.utils.urllib.request.urlopen') as mock_urlopen, \ patch('openlp.core.utils._get_user_agent') as mock_get_user_agent, \ - patch('openlp.core.utils.Registry') as MockRegistry: + patch('openlp.core.common.Registry') as MockRegistry: # GIVEN: Mocked out objects, a fake URL mocked_request_object = MagicMock() MockRequest.return_value = mocked_request_object