forked from openlp/openlp
start to fix tests
This commit is contained in:
parent
cad03b9abd
commit
b7001116da
@ -440,11 +440,14 @@ def get_file_encoding(filename):
|
|||||||
log.exception('Error detecting file encoding')
|
log.exception('Error detecting file encoding')
|
||||||
|
|
||||||
|
|
||||||
def json_default(o):
|
def json_default(obj):
|
||||||
"""
|
"""
|
||||||
Function to help save objects as JSON
|
Function to help save objects as JSON
|
||||||
|
|
||||||
:param o: object
|
:param obj: object
|
||||||
:return: the object dictionary
|
:return: the object dictionary
|
||||||
"""
|
"""
|
||||||
return o.__dict__
|
try:
|
||||||
|
return obj.__dict__
|
||||||
|
except:
|
||||||
|
raise TypeError("Unserializable object {} of type {}".format(obj, type(obj)))
|
||||||
|
@ -379,10 +379,12 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
|
|||||||
critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.'))
|
critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.'))
|
||||||
return
|
return
|
||||||
theme = item.data(QtCore.Qt.UserRole)
|
theme = item.data(QtCore.Qt.UserRole)
|
||||||
path, filter_used = QtWidgets.QFileDialog.getSaveFileName(self.main_window,
|
path, filter_used = \
|
||||||
translate('OpenLP.ThemeManager', 'Save Theme - ({name})').format(name=theme),
|
QtWidgets.QFileDialog.getSaveFileName(self.main_window,
|
||||||
Settings().value(self.settings_section + '/last directory export'),
|
translate('OpenLP.ThemeManager', 'Save Theme - ({name})').
|
||||||
translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
|
format(name=theme),
|
||||||
|
Settings().value(self.settings_section + '/last directory export'),
|
||||||
|
translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
|
||||||
self.application.set_busy_cursor()
|
self.application.set_busy_cursor()
|
||||||
if path:
|
if path:
|
||||||
Settings().setValue(self.settings_section + '/last directory export', path)
|
Settings().setValue(self.settings_section + '/last directory export', path)
|
||||||
|
@ -26,7 +26,6 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from tempfile import mkdtemp
|
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
@ -65,7 +64,7 @@ class TestThemeManager(TestCase):
|
|||||||
mocked_zipfile_init.return_value = None
|
mocked_zipfile_init.return_value = None
|
||||||
|
|
||||||
# WHEN: The theme is exported
|
# WHEN: The theme is exported
|
||||||
theme_manager._export_theme(os.path.join('some', 'path'), 'Default')
|
theme_manager._export_theme(os.path.join('some', 'path', 'Default.otz'), 'Default')
|
||||||
|
|
||||||
# THEN: The zipfile should be created at the given path
|
# THEN: The zipfile should be created at the given path
|
||||||
mocked_zipfile_init.assert_called_with(os.path.join('some', 'path', 'Default.otz'), 'w')
|
mocked_zipfile_init.assert_called_with(os.path.join('some', 'path', 'Default.otz'), 'w')
|
||||||
@ -128,8 +127,9 @@ class TestThemeManager(TestCase):
|
|||||||
theme_manager.path = ''
|
theme_manager.path = ''
|
||||||
mocked_theme = MagicMock()
|
mocked_theme = MagicMock()
|
||||||
mocked_theme.theme_name = 'themename'
|
mocked_theme.theme_name = 'themename'
|
||||||
mocked_theme.extract_formatted_xml = MagicMock()
|
mocked_theme.filename = "filename"
|
||||||
mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode()
|
# mocked_theme.extract_formatted_xml = MagicMock()
|
||||||
|
# mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode()
|
||||||
|
|
||||||
# WHEN: Calling _write_theme with path to different images
|
# WHEN: Calling _write_theme with path to different images
|
||||||
file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg')
|
file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg')
|
||||||
|
Loading…
Reference in New Issue
Block a user