Add tests

This commit is contained in:
Tim Bentley 2015-02-28 09:41:06 +00:00
parent e9be4a9143
commit 1d82bc534c
2 changed files with 24 additions and 1 deletions

View File

@ -39,6 +39,12 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties):
Constructor Constructor
""" """
super(FileRenameForm, self).__init__(Registry().get('main_window')) super(FileRenameForm, self).__init__(Registry().get('main_window'))
self._setup()
def _setup(self):
"""
Set up the class. This method is mocked out by the tests.
"""
self.setupUi(self) self.setupUi(self)
def exec_(self, copy=False): def exec_(self, copy=False):

View File

@ -25,7 +25,7 @@ Interface tests to test the themeManager class and related methods.
from unittest import TestCase from unittest import TestCase
from openlp.core.common import Registry, Settings from openlp.core.common import Registry, Settings
from openlp.core.ui import ThemeManager from openlp.core.ui import ThemeManager, ThemeForm, FileRenameForm
from tests.functional import patch, MagicMock from tests.functional import patch, MagicMock
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -105,3 +105,20 @@ class TestThemeManager(TestCase, TestMixin):
new_theme.trigger() new_theme.trigger()
assert mocked_event.call_count == 1, 'The on_add_theme method should have been called once' assert mocked_event.call_count == 1, 'The on_add_theme method should have been called once'
@patch('openlp.core.ui.themeform.ThemeForm._setup')
@patch('openlp.core.ui.filerenameform.FileRenameForm._setup')
def bootstrap_post_test(self, mocked_theme_form, mocked_rename_form):
"""
Test the functions of bootstrap_post_setup are called.
"""
# GIVEN:
self.theme_manager.load_themes = MagicMock()
self.theme_manager.path = MagicMock()
# WHEN:
self.theme_manager.bootstrap_post_set_up()
# THEN:
self.assertEqual(self.theme_manager.path, self.theme_manager.theme_form.path)
self.assertEqual(1, self.theme_manager.load_themes.call_count, "load_themes should have been called once")