From 1d82bc534cfd1411af4449a297509e94a5c5c657 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 28 Feb 2015 09:41:06 +0000 Subject: [PATCH] Add tests --- openlp/core/ui/filerenameform.py | 6 ++++++ .../openlp_core_ui/test_thememanager.py | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 9d382ec3d..7446cdf9e 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -39,6 +39,12 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties): Constructor """ 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) def exec_(self, copy=False): diff --git a/tests/interfaces/openlp_core_ui/test_thememanager.py b/tests/interfaces/openlp_core_ui/test_thememanager.py index 38bbbb9d9..9a4c78362 100644 --- a/tests/interfaces/openlp_core_ui/test_thememanager.py +++ b/tests/interfaces/openlp_core_ui/test_thememanager.py @@ -25,7 +25,7 @@ Interface tests to test the themeManager class and related methods. from unittest import TestCase 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.helpers.testmixin import TestMixin @@ -105,3 +105,20 @@ class TestThemeManager(TestCase, TestMixin): new_theme.trigger() 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")