From 04d3efef9e182a028d8c6c465270a0ddf10429b5 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 7 Jun 2019 23:05:02 +0200 Subject: [PATCH] fix some broken tests --- openlp/core/ui/thememanager.py | 2 +- .../openlp_core/ui/test_thememanager.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 986a38135..46d067970 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -639,7 +639,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R return False return True - def save_theme(self, theme, image_source_path, image_destination_path, image=None): + def save_theme(self, theme, image_source_path=None, image_destination_path=None, image=None): """ Writes the theme to the disk and handles the background image if necessary diff --git a/tests/functional/openlp_core/ui/test_thememanager.py b/tests/functional/openlp_core/ui/test_thememanager.py index b4d50331b..3b015f238 100644 --- a/tests/functional/openlp_core/ui/test_thememanager.py +++ b/tests/functional/openlp_core/ui/test_thememanager.py @@ -83,7 +83,7 @@ class TestThemeManager(TestCase): @patch('openlp.core.ui.thememanager.shutil') @patch('openlp.core.ui.thememanager.create_paths') - def test_write_theme_same_image(self, mocked_create_paths, mocked_shutil): + def test_save_theme_same_image(self, mocked_create_paths, mocked_shutil): """ Test that we don't try to overwrite a theme background image with itself """ @@ -98,16 +98,16 @@ class TestThemeManager(TestCase): mocked_theme.extract_formatted_xml = MagicMock() mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode() - # WHEN: Calling _write_theme with path to the same image, but the path written slightly different + # WHEN: Calling save_theme with path to the same image, but the path written slightly different file_path_1 = RESOURCE_PATH / 'church.jpg' - theme_manager._write_theme(mocked_theme, file_path_1, file_path_1) + theme_manager.save_theme(mocked_theme, file_path_1, file_path_1) # THEN: The mocked_copyfile should not have been called assert mocked_shutil.copyfile.called is False, 'copyfile should not be called' @patch('openlp.core.ui.thememanager.shutil') @patch('openlp.core.ui.thememanager.create_paths') - def test_write_theme_diff_images(self, mocked_create_paths, mocked_shutil): + def test_save_theme_diff_images(self, mocked_create_paths, mocked_shutil): """ Test that we do overwrite a theme background image when a new is submitted """ @@ -121,15 +121,15 @@ class TestThemeManager(TestCase): mocked_theme.theme_name = 'themename' mocked_theme.filename = "filename" - # WHEN: Calling _write_theme with path to different images + # WHEN: Calling save_theme with path to different images file_path_1 = RESOURCE_PATH / 'church.jpg' file_path_2 = RESOURCE_PATH / 'church2.jpg' - theme_manager._write_theme(mocked_theme, file_path_1, file_path_2) + theme_manager.save_theme(mocked_theme, file_path_1, file_path_2) # THEN: The mocked_copyfile should not have been called assert mocked_shutil.copyfile.called is True, 'copyfile should be called' - def test_write_theme_special_char_name(self): + def test_save_theme_special_char_name(self): """ Test that we can save themes with special characters in the name """ @@ -142,8 +142,8 @@ class TestThemeManager(TestCase): mocked_theme.theme_name = 'theme 愛 name' mocked_theme.export_theme.return_value = "{}" - # WHEN: Calling _write_theme with a theme with a name with special characters in it - theme_manager._write_theme(mocked_theme) + # WHEN: Calling save_theme with a theme with a name with special characters in it + theme_manager.save_theme(mocked_theme) # THEN: It should have been created assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \