forked from openlp/openlp
This commit is contained in:
parent
022f899c10
commit
e145be9873
@ -47,8 +47,7 @@ from openlp.core.lib.ui import UiStrings, create_action
|
||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
|
||||
MediaDockManager, ShortcutListForm, FormattingTagForm
|
||||
from openlp.core.ui.media import MediaController
|
||||
from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_application_version, \
|
||||
get_filesystem_encoding
|
||||
from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_application_version
|
||||
from openlp.core.utils.actions import ActionList, CategoryOrder
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
|
||||
@ -903,7 +902,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# Make sure it's a .conf file.
|
||||
if not export_file_name.endswith(u'conf'):
|
||||
export_file_name += u'.conf'
|
||||
temp_file = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', u'exportConf.tmp')
|
||||
temp_file = os.path.join(gettempdir(), u'openlp', u'exportConf.tmp')
|
||||
self.save_settings()
|
||||
setting_sections = []
|
||||
# Add main sections.
|
||||
|
@ -39,7 +39,7 @@ from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||
from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding
|
||||
from openlp.core.utils import AppLocation, delete_file
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, BiblesResourcesDB
|
||||
from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
|
||||
|
||||
@ -71,7 +71,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.suffix = u'.sqlite'
|
||||
self.settings_section = u'bibles'
|
||||
self.path = AppLocation.get_section_data_path(self.settings_section)
|
||||
self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
|
||||
self.temp_dir = os.path.join(gettempdir(), u'openlp')
|
||||
self.files = self.manager.old_bible_databases
|
||||
self.success = {}
|
||||
self.new_bibles = {}
|
||||
|
@ -5,42 +5,13 @@ from unittest import TestCase
|
||||
|
||||
from mock import patch
|
||||
|
||||
from openlp.core.utils import clean_filename, get_filesystem_encoding, _get_frozen_path, get_locale_key, \
|
||||
get_natural_key, split_filename
|
||||
from openlp.core.utils import clean_filename, _get_frozen_path, get_locale_key, get_natural_key, split_filename
|
||||
|
||||
|
||||
class TestUtils(TestCase):
|
||||
"""
|
||||
A test suite to test out various methods around the AppLocation class.
|
||||
"""
|
||||
def get_filesystem_encoding_test(self):
|
||||
"""
|
||||
Test the get_filesystem_encoding() function
|
||||
"""
|
||||
with patch(u'openlp.core.utils.sys.getfilesystemencoding') as mocked_getfilesystemencoding, \
|
||||
patch(u'openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding:
|
||||
# GIVEN: sys.getfilesystemencoding returns "cp1252"
|
||||
mocked_getfilesystemencoding.return_value = u'cp1252'
|
||||
|
||||
# WHEN: get_filesystem_encoding() is called
|
||||
result = get_filesystem_encoding()
|
||||
|
||||
# THEN: getdefaultencoding should have been called
|
||||
mocked_getfilesystemencoding.assert_called_with()
|
||||
assert not mocked_getdefaultencoding.called
|
||||
assert result == u'cp1252', u'The result should be "cp1252"'
|
||||
|
||||
# GIVEN: sys.getfilesystemencoding returns None and sys.getdefaultencoding returns "utf-8"
|
||||
mocked_getfilesystemencoding.return_value = None
|
||||
mocked_getdefaultencoding.return_value = u'utf-8'
|
||||
|
||||
# WHEN: get_filesystem_encoding() is called
|
||||
result = get_filesystem_encoding()
|
||||
|
||||
# THEN: getdefaultencoding should have been called
|
||||
mocked_getfilesystemencoding.assert_called_with()
|
||||
mocked_getdefaultencoding.assert_called_with()
|
||||
assert result == u'utf-8', u'The result should be "utf-8"'
|
||||
|
||||
def get_frozen_path_test(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user