forked from openlp/openlp
Pep8
This commit is contained in:
parent
85587ce2f3
commit
5dd4b8e386
@ -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')
|
||||
return resolver.resolve('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user