forked from openlp/openlp
fix some broken tests
This commit is contained in:
parent
ad9d1df172
commit
04d3efef9e
@ -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
|
||||
|
||||
|
@ -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, \
|
||||
|
Loading…
Reference in New Issue
Block a user