Remove the class, makes the tests run faster.

This commit is contained in:
Raoul Snyman 2016-11-04 17:13:37 +02:00
parent 5e765252b6
commit b9cf077b36

View File

@ -29,11 +29,7 @@ from openlp.plugins.presentations.lib.libreofficeserver import LibreOfficeServer
from tests.functional import MagicMock, patch, call from tests.functional import MagicMock, patch, call
class TestLibreOfficeServer(TestCase): def test_constructor():
"""
Test the LibreOfficeServer Class
"""
def test_constructor(self):
""" """
Test the Constructor from the server Test the Constructor from the server
""" """
@ -49,7 +45,7 @@ class TestLibreOfficeServer(TestCase):
assert server._process is None assert server._process is None
@patch('openlp.plugins.presentations.lib.libreofficeserver.Popen') @patch('openlp.plugins.presentations.lib.libreofficeserver.Popen')
def test_start_process(self, MockedPopen): def test_start_process(MockedPopen):
""" """
Test that the correct command is issued to run LibreOffice Test that the correct command is issued to run LibreOffice
""" """
@ -74,7 +70,7 @@ class TestLibreOfficeServer(TestCase):
assert server._process is mocked_process assert server._process is mocked_process
@patch('openlp.plugins.presentations.lib.libreofficeserver.uno') @patch('openlp.plugins.presentations.lib.libreofficeserver.uno')
def test_setup_desktop(self, mocked_uno): def test_setup_desktop(mocked_uno):
""" """
Test that setting up the desktop works correctly Test that setting up the desktop works correctly
""" """
@ -98,20 +94,18 @@ class TestLibreOfficeServer(TestCase):
mocked_uno.getComponentContext.assert_called_once_with() mocked_uno.getComponentContext.assert_called_once_with()
mocked_context.ServiceManager.createInstanceWithContext.assert_called_once_with( mocked_context.ServiceManager.createInstanceWithContext.assert_called_once_with(
'com.sun.star.bridge.UnoUrlResolver', mocked_context) 'com.sun.star.bridge.UnoUrlResolver', mocked_context)
self.assertEqual( expected_calls = [
[
call('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext'), call('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext'),
call('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext') call('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext')
], ]
mocked_resolver.resolve.call_args_list assert mocked_resolver.resolve.call_args_list == expected_calls
)
MockedServiceManager.createInstanceWithContext.assert_called_once_with( MockedServiceManager.createInstanceWithContext.assert_called_once_with(
'com.sun.star.frame.Desktop', mocked_uno_instance) 'com.sun.star.frame.Desktop', mocked_uno_instance)
assert server._manager is MockedServiceManager assert server._manager is MockedServiceManager
assert server._desktop is mocked_desktop assert server._desktop is mocked_desktop
@patch('openlp.plugins.presentations.lib.libreofficeserver.PropertyValue') @patch('openlp.plugins.presentations.lib.libreofficeserver.PropertyValue')
def test_create_property(self, MockedPropertyValue): def test_create_property(MockedPropertyValue):
""" """
Test that the _create_property() method works correctly Test that the _create_property() method works correctly
""" """
@ -127,7 +121,7 @@ class TestLibreOfficeServer(TestCase):
assert prop.Name == name assert prop.Name == name
assert prop.Value == value assert prop.Value == value
def test_get_text_from_page_slide_text(self): def test_get_text_from_page_slide_text():
""" """
Test that the _get_text_from_page() method gives us nothing for slide text Test that the _get_text_from_page() method gives us nothing for slide text
""" """
@ -153,7 +147,7 @@ class TestLibreOfficeServer(TestCase):
# THE: The text is correct # THE: The text is correct
assert text == 'Page Text\n' assert text == 'Page Text\n'
def test_get_text_from_page_title(self): def test_get_text_from_page_title():
""" """
Test that the _get_text_from_page() method gives us the text from the titles Test that the _get_text_from_page() method gives us the text from the titles
""" """
@ -179,7 +173,7 @@ class TestLibreOfficeServer(TestCase):
# THEN: The text should be correct # THEN: The text should be correct
assert text == 'Page Title\n' assert text == 'Page Title\n'
def test_get_text_from_page_notes(self): def test_get_text_from_page_notes():
""" """
Test that the _get_text_from_page() method gives us the text from the notes Test that the _get_text_from_page() method gives us the text from the notes
""" """
@ -207,7 +201,7 @@ class TestLibreOfficeServer(TestCase):
# THEN: The text should be correct # THEN: The text should be correct
assert text == 'Page Notes\n' assert text == 'Page Notes\n'
def test_has_desktop_no_desktop(self): def test_has_desktop_no_desktop():
""" """
Test the has_desktop() method when there's no desktop Test the has_desktop() method when there's no desktop
""" """
@ -220,7 +214,7 @@ class TestLibreOfficeServer(TestCase):
# THEN: The result should be False # THEN: The result should be False
assert result is False assert result is False
def test_has_desktop(self): def test_has_desktop():
""" """
Test the has_desktop() method Test the has_desktop() method
""" """
@ -234,7 +228,7 @@ class TestLibreOfficeServer(TestCase):
# THEN: The result should be True # THEN: The result should be True
assert result is True assert result is True
def test_shutdown(self): def test_shutdown():
""" """
Test the shutdown method Test the shutdown method
""" """
@ -273,7 +267,7 @@ class TestLibreOfficeServer(TestCase):
server._process.kill.assert_called_once_with() server._process.kill.assert_called_once_with()
@patch('openlp.plugins.presentations.lib.libreofficeserver.uno') @patch('openlp.plugins.presentations.lib.libreofficeserver.uno')
def test_load_presentation(self, mocked_uno): def test_load_presentation(mocked_uno):
""" """
Test the load_presentation() method Test the load_presentation() method
""" """
@ -308,7 +302,7 @@ class TestLibreOfficeServer(TestCase):
@patch('openlp.plugins.presentations.lib.libreofficeserver.uno') @patch('openlp.plugins.presentations.lib.libreofficeserver.uno')
@patch('openlp.plugins.presentations.lib.libreofficeserver.os') @patch('openlp.plugins.presentations.lib.libreofficeserver.os')
def test_extract_thumbnails(self, mocked_os, mocked_uno): def test_extract_thumbnails(mocked_os, mocked_uno):
""" """
Test the extract_thumbnails() method Test the extract_thumbnails() method
""" """