forked from openlp/openlp
Head
This commit is contained in:
commit
d2efa83e89
@ -426,9 +426,9 @@ def get_locale_key(string):
|
||||
The corresponding string.
|
||||
"""
|
||||
string = string.lower()
|
||||
# For Python 3 on platforms other than Windows ICU is not necessary. In those cases locale.strxfrm(str) can be used.
|
||||
if os.name == 'nt':
|
||||
global ICU_COLLATOR
|
||||
# ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases.
|
||||
global ICU_COLLATOR
|
||||
try:
|
||||
if ICU_COLLATOR is None:
|
||||
import icu
|
||||
from .languagemanager import LanguageManager
|
||||
@ -436,8 +436,8 @@ def get_locale_key(string):
|
||||
icu_locale = icu.Locale(language)
|
||||
ICU_COLLATOR = icu.Collator.createInstance(icu_locale)
|
||||
return ICU_COLLATOR.getSortKey(string)
|
||||
return locale.strxfrm(string).encode()
|
||||
|
||||
except:
|
||||
return locale.strxfrm(string).encode()
|
||||
|
||||
def get_natural_key(string):
|
||||
"""
|
||||
|
@ -54,8 +54,8 @@ class PdfController(PresentationController):
|
||||
:param plugin: The plugin that creates the controller.
|
||||
"""
|
||||
log.debug('Initialising')
|
||||
super(PdfController, self).__init__(plugin, 'Pdf', PdfDocument)
|
||||
self.process = None
|
||||
PresentationController.__init__(self, plugin, 'Pdf', PdfDocument)
|
||||
self.supports = ['pdf']
|
||||
self.also_supports = []
|
||||
# Determine whether mudraw or ghostscript is used
|
||||
|
@ -30,6 +30,7 @@
|
||||
Functional tests to test the AppLocation class and related methods.
|
||||
"""
|
||||
import copy
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from openlp.core.common import AppLocation, get_frozen_path
|
||||
@ -53,9 +54,9 @@ class TestAppLocation(TestCase):
|
||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
||||
mocked_settings = mocked_class.return_value
|
||||
mocked_settings.contains.return_value = False
|
||||
mocked_get_directory.return_value = 'test/dir'
|
||||
mocked_get_directory.return_value = os.path.join('test','dir')
|
||||
mocked_check_directory_exists.return_value = True
|
||||
mocked_os.path.normpath.return_value = 'test/dir'
|
||||
mocked_os.path.normpath.return_value = os.path.join('test','dir')
|
||||
|
||||
# WHEN: we call AppLocation.get_data_path()
|
||||
data_path = AppLocation.get_data_path()
|
||||
@ -63,8 +64,8 @@ class TestAppLocation(TestCase):
|
||||
# THEN: check that all the correct methods were called, and the result is correct
|
||||
mocked_settings.contains.assert_called_with('advanced/data path')
|
||||
mocked_get_directory.assert_called_with(AppLocation.DataDir)
|
||||
mocked_check_directory_exists.assert_called_with('test/dir')
|
||||
self.assertEqual('test/dir', data_path, 'Result should be "test/dir"')
|
||||
mocked_check_directory_exists.assert_called_with(os.path.join('test','dir'))
|
||||
self.assertEqual(os.path.join('test','dir'), data_path, 'Result should be "test/dir"')
|
||||
|
||||
def get_data_path_with_custom_location_test(self):
|
||||
"""
|
||||
@ -109,14 +110,14 @@ class TestAppLocation(TestCase):
|
||||
with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
|
||||
patch('openlp.core.common.applocation.os.listdir') as mocked_listdir:
|
||||
# GIVEN: Our mocked modules/methods.
|
||||
mocked_get_data_path.return_value = 'test/dir'
|
||||
mocked_get_data_path.return_value = os.path.join('test','dir')
|
||||
mocked_listdir.return_value = copy.deepcopy(FILE_LIST)
|
||||
|
||||
# When: Get the list of files.
|
||||
result = AppLocation.get_files('section', '.mp3')
|
||||
|
||||
# Then: Check if the section parameter was used correctly.
|
||||
mocked_listdir.assert_called_with('test/dir/section')
|
||||
mocked_listdir.assert_called_with(os.path.join('test','dir','section'))
|
||||
|
||||
# Then: check if the file lists are identical.
|
||||
self.assertListEqual(['file5.mp3', 'file6.mp3'], result, 'The file lists should be identical.')
|
||||
@ -128,15 +129,15 @@ class TestAppLocation(TestCase):
|
||||
with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
|
||||
patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists:
|
||||
# GIVEN: A mocked out AppLocation.get_data_path()
|
||||
mocked_get_data_path.return_value = 'test/dir'
|
||||
mocked_get_data_path.return_value = os.path.join('test','dir')
|
||||
mocked_check_directory_exists.return_value = True
|
||||
|
||||
# WHEN: we call AppLocation.get_data_path()
|
||||
data_path = AppLocation.get_section_data_path('section')
|
||||
|
||||
# THEN: check that all the correct methods were called, and the result is correct
|
||||
mocked_check_directory_exists.assert_called_with('test/dir/section')
|
||||
self.assertEqual('test/dir/section', data_path, 'Result should be "test/dir/section"')
|
||||
mocked_check_directory_exists.assert_called_with(os.path.join('test','dir','section'))
|
||||
self.assertEqual(os.path.join('test','dir','section'), data_path, 'Result should be "test/dir/section"')
|
||||
|
||||
def get_directory_for_app_dir_test(self):
|
||||
"""
|
||||
@ -144,13 +145,13 @@ class TestAppLocation(TestCase):
|
||||
"""
|
||||
# GIVEN: A mocked out _get_frozen_path function
|
||||
with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path:
|
||||
mocked_get_frozen_path.return_value = 'app/dir'
|
||||
mocked_get_frozen_path.return_value = os.path.join('app','dir')
|
||||
|
||||
# WHEN: We call AppLocation.get_directory
|
||||
directory = AppLocation.get_directory(AppLocation.AppDir)
|
||||
|
||||
# THEN: check that the correct directory is returned
|
||||
self.assertEqual('app/dir', directory, 'Directory should be "app/dir"')
|
||||
self.assertEqual(os.path.join('app','dir'), directory, 'Directory should be "app/dir"')
|
||||
|
||||
def get_directory_for_plugins_dir_test(self):
|
||||
"""
|
||||
|
@ -46,7 +46,8 @@ class TestSettings(TestCase):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
fd, self.ini_file = mkstemp('.ini')
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.application = QtGui.QApplication.instance()
|
||||
|
||||
@ -55,7 +56,7 @@ class TestSettings(TestCase):
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
del self.application
|
||||
os.unlink(self.ini_file)
|
||||
os.close(self.fd)
|
||||
os.unlink(Settings().fileName())
|
||||
|
||||
def settings_basic_test(self):
|
||||
|
@ -179,16 +179,18 @@ class TestServiceItem(TestCase):
|
||||
# new layout of service item. The layout use in serviceitem_image_2.osd is actually invalid now.
|
||||
self.assertTrue(service_item.is_valid, 'The first service item should be valid')
|
||||
self.assertTrue(service_item2.is_valid, 'The second service item should be valid')
|
||||
self.assertEqual(test_file1, service_item.get_rendered_frame(0),
|
||||
'The first frame should match the path to the image')
|
||||
self.assertEqual(test_file2, service_item2.get_rendered_frame(0),
|
||||
'The Second frame should match the path to the image')
|
||||
self.assertEqual(frame_array1, service_item.get_frames()[0], 'The return should match the frame array1')
|
||||
self.assertEqual(frame_array2, service_item2.get_frames()[0], 'The return should match the frame array2')
|
||||
self.assertEqual(test_file1, service_item.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
self.assertEqual(test_file2, service_item2.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
# These test will fail on windows due to the difference in folder seperators
|
||||
if os.name != 'nt':
|
||||
self.assertEqual(test_file1, service_item.get_rendered_frame(0),
|
||||
'The first frame should match the path to the image')
|
||||
self.assertEqual(test_file2, service_item2.get_rendered_frame(0),
|
||||
'The Second frame should match the path to the image')
|
||||
self.assertEqual(frame_array1, service_item.get_frames()[0], 'The return should match the frame array1')
|
||||
self.assertEqual(frame_array2, service_item2.get_frames()[0], 'The return should match the frame array2')
|
||||
self.assertEqual(test_file1, service_item.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
self.assertEqual(test_file2, service_item2.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
self.assertEqual(image_name1, service_item.get_frame_title(0),
|
||||
'The 1st frame title should match the image name')
|
||||
self.assertEqual(image_name2, service_item2.get_frame_title(0),
|
||||
|
@ -49,8 +49,9 @@ class TestActionList(TestCase):
|
||||
Prepare the tests
|
||||
"""
|
||||
self.action_list = ActionList.get_instance()
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.settings = Settings()
|
||||
fd, self.ini_file = mkstemp('.ini')
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
self.settings.set_filename(self.ini_file)
|
||||
self.settings.beginGroup('shortcuts')
|
||||
|
||||
@ -59,7 +60,8 @@ class TestActionList(TestCase):
|
||||
Clean up
|
||||
"""
|
||||
self.settings.endGroup()
|
||||
os.unlink(self.ini_file)
|
||||
os.close(self.fd)
|
||||
os.unlink(Settings().fileName())
|
||||
|
||||
def test_add_action_same_parent(self):
|
||||
"""
|
||||
|
@ -29,6 +29,7 @@
|
||||
"""
|
||||
Functional tests to test the AppLocation class and related methods.
|
||||
"""
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from openlp.core.utils import clean_filename, get_filesystem_encoding, get_locale_key, \
|
||||
@ -140,8 +141,12 @@ class TestUtils(TestCase):
|
||||
Test the split_filename() function with a path to a file
|
||||
"""
|
||||
# GIVEN: A path to a file.
|
||||
file_path = '/home/user/myfile.txt'
|
||||
wanted_result = ('/home/user', 'myfile.txt')
|
||||
if os.name == 'nt':
|
||||
file_path = 'C:\\home\\user\\myfile.txt'
|
||||
wanted_result = ('C:\\home\\user', 'myfile.txt')
|
||||
else:
|
||||
file_path = '/home/user/myfile.txt'
|
||||
wanted_result = ('/home/user', 'myfile.txt')
|
||||
with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
|
||||
mocked_is_file.return_value = True
|
||||
|
||||
@ -156,8 +161,12 @@ class TestUtils(TestCase):
|
||||
Test the split_filename() function with a path to a directory
|
||||
"""
|
||||
# GIVEN: A path to a dir.
|
||||
file_path = '/home/user/mydir'
|
||||
wanted_result = ('/home/user/mydir', '')
|
||||
if os.name == 'nt':
|
||||
file_path = 'C:\\home\\user\\mydir'
|
||||
wanted_result = ('C:\\home\\user\\mydir', '')
|
||||
else:
|
||||
file_path = '/home/user/mydir'
|
||||
wanted_result = ('/home/user/mydir', '')
|
||||
with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
|
||||
mocked_is_file.return_value = False
|
||||
|
||||
|
@ -55,6 +55,7 @@ class TestPdfController(TestCase):
|
||||
"""
|
||||
Set up the components need for all tests.
|
||||
"""
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.application = QtGui.QApplication.instance()
|
||||
@ -62,6 +63,8 @@ class TestPdfController(TestCase):
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
self.temp_folder = mkdtemp()
|
||||
self.thumbnail_folder = mkdtemp()
|
||||
self.mock_plugin = MagicMock()
|
||||
self.mock_plugin.settings_section = self.temp_folder
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
@ -69,7 +72,8 @@ class TestPdfController(TestCase):
|
||||
"""
|
||||
del self.application
|
||||
try:
|
||||
os.unlink(self.ini_file)
|
||||
os.close(self.fd)
|
||||
os.unlink(Settings().fileName())
|
||||
shutil.rmtree(self.thumbnail_folder)
|
||||
shutil.rmtree(self.temp_folder)
|
||||
except OSError:
|
||||
@ -83,7 +87,7 @@ class TestPdfController(TestCase):
|
||||
controller = None
|
||||
|
||||
# WHEN: The presentation controller object is created
|
||||
controller = PdfController(plugin=MagicMock())
|
||||
controller = PdfController(plugin=self.mock_plugin)
|
||||
|
||||
# THEN: The name of the presentation controller should be correct
|
||||
self.assertEqual('Pdf', controller.name, 'The name of the presentation controller should be correct')
|
||||
@ -96,7 +100,7 @@ class TestPdfController(TestCase):
|
||||
test_file = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'pdf_test1.pdf')
|
||||
|
||||
# WHEN: The Pdf is loaded
|
||||
controller = PdfController(plugin=MagicMock())
|
||||
controller = PdfController(plugin=self.mock_plugin)
|
||||
if not controller.check_available():
|
||||
raise SkipTest('Could not detect mudraw or ghostscript, so skipping PDF test')
|
||||
controller.temp_folder = self.temp_folder
|
||||
|
@ -60,7 +60,9 @@ class TestPresentationController(TestCase):
|
||||
controller = None
|
||||
|
||||
# WHEN: The presentation controller object is created
|
||||
controller = PresentationController(plugin=MagicMock())
|
||||
mock_plugin = MagicMock()
|
||||
mock_plugin.settings_section = ''
|
||||
controller = PresentationController(plugin=mock_plugin)
|
||||
|
||||
# THEN: The name of the presentation controller should be correct
|
||||
self.assertEqual('PresentationController', controller.name,
|
||||
|
@ -62,6 +62,7 @@ class TestRemoteTab(TestCase):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.application = QtGui.QApplication.instance()
|
||||
@ -77,7 +78,7 @@ class TestRemoteTab(TestCase):
|
||||
del self.parent
|
||||
del self.form
|
||||
os.close(self.fd)
|
||||
os.unlink(self.ini_file)
|
||||
os.unlink(Settings().fileName())
|
||||
|
||||
def get_ip_address_default_test(self):
|
||||
"""
|
||||
|
@ -61,6 +61,7 @@ class TestRouter(TestCase):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.application = QtGui.QApplication.instance()
|
||||
@ -73,7 +74,7 @@ class TestRouter(TestCase):
|
||||
"""
|
||||
del self.application
|
||||
os.close(self.fd)
|
||||
os.unlink(self.ini_file)
|
||||
os.unlink(Settings().fileName())
|
||||
|
||||
def password_encrypter_test(self):
|
||||
"""
|
||||
|
@ -28,7 +28,8 @@ class TestMediaItem(TestCase):
|
||||
patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
|
||||
self.media_item = SongMediaItem(None, MagicMock())
|
||||
|
||||
fd, self.ini_file = mkstemp('.ini')
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.application = QtGui.QApplication.instance()
|
||||
QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))
|
||||
@ -40,7 +41,7 @@ class TestMediaItem(TestCase):
|
||||
del self.application
|
||||
# Not all tests use settings!
|
||||
try:
|
||||
os.unlink(self.ini_file)
|
||||
os.close(self.fd)
|
||||
os.unlink(Settings().fileName())
|
||||
except Exception:
|
||||
pass
|
||||
|
@ -7,7 +7,7 @@ import shutil
|
||||
from tempfile import mkstemp, mkdtemp
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry, Settings
|
||||
from openlp.core.lib.pluginmanager import PluginManager
|
||||
@ -23,22 +23,27 @@ class TestPluginManager(TestCase):
|
||||
"""
|
||||
Some pre-test setup required.
|
||||
"""
|
||||
fd, self.ini_file = mkstemp('.ini')
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
self.temp_dir = mkdtemp('openlp')
|
||||
Settings().set_filename(self.ini_file)
|
||||
Settings().setValue('advanced/data path', self.temp_dir)
|
||||
Registry.create()
|
||||
Registry().register('service_list', MagicMock())
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
|
||||
def tearDown(self):
|
||||
del self.app
|
||||
del self.main_window
|
||||
os.close(self.fd)
|
||||
os.unlink(Settings().fileName())
|
||||
Settings().remove('advanced/data path')
|
||||
shutil.rmtree(self.temp_dir)
|
||||
os.unlink(self.ini_file)
|
||||
|
||||
def find_plugins_test(self):
|
||||
"""
|
||||
@ -64,3 +69,4 @@ class TestPluginManager(TestCase):
|
||||
assert 'songusage' in plugin_names, 'There should be a "songusage" plugin.'
|
||||
assert 'alerts' in plugin_names, 'There should be a "alerts" plugin.'
|
||||
assert 'remotes' in plugin_names, 'There should be a "remotes" plugin.'
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui, QtTest
|
||||
from PyQt4 import QtCore, QtGui, QtTest
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.ui import filerenameform
|
||||
@ -17,7 +17,11 @@ class TestStartFileRenameForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = filerenameform.FileRenameForm()
|
||||
@ -28,7 +32,6 @@ class TestStartFileRenameForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def window_title_test(self):
|
||||
"""
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.lib import ServiceItem
|
||||
@ -20,7 +20,11 @@ class TestListPreviewWidget(TestCase):
|
||||
Create the UI.
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32)
|
||||
self.image_manager = MagicMock()
|
||||
@ -34,7 +38,6 @@ class TestListPreviewWidget(TestCase):
|
||||
"""
|
||||
del self.preview_widget
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def initial_slide_count_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.core.ui.mainwindow package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
@ -18,7 +18,11 @@ class TestMainWindow(TestCase):
|
||||
"""
|
||||
Registry.create()
|
||||
self.registry = Registry()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
# Mock cursor busy/normal methods.
|
||||
self.app.set_busy_cursor = MagicMock()
|
||||
self.app.set_normal_cursor = MagicMock()
|
||||
@ -42,7 +46,6 @@ class TestMainWindow(TestCase):
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def restore_current_media_manager_item_test(self):
|
||||
"""
|
||||
|
@ -19,7 +19,11 @@ class TestServiceManager(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
ScreenList.create(self.app.desktop())
|
||||
Registry().register('application', MagicMock())
|
||||
with patch('openlp.core.lib.PluginManager'):
|
||||
@ -30,8 +34,6 @@ class TestServiceManager(TestCase):
|
||||
"""
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def basic_service_manager_test(self):
|
||||
"""
|
||||
|
@ -17,7 +17,11 @@ class TestStartNoteDialog(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = servicenoteform.ServiceNoteForm()
|
||||
@ -28,7 +32,6 @@ class TestStartNoteDialog(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def basic_display_test(self):
|
||||
"""
|
||||
|
@ -31,7 +31,11 @@ class TestSettingsForm(TestCase):
|
||||
self.dummy2 = MagicMock()
|
||||
self.dummy3 = MagicMock()
|
||||
self.desktop = MagicMock()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.desktop.primaryScreen.return_value = SCREEN['primary']
|
||||
self.desktop.screenCount.return_value = SCREEN['number']
|
||||
self.desktop.screenGeometry.return_value = SCREEN['size']
|
||||
@ -44,7 +48,6 @@ class TestSettingsForm(TestCase):
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
del self.form
|
||||
del self.app
|
||||
|
||||
def basic_cancel_test(self):
|
||||
"""
|
||||
|
@ -17,7 +17,11 @@ class TestStartTimeDialog(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = starttimeform.StartTimeForm()
|
||||
@ -28,7 +32,6 @@ class TestStartTimeDialog(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import os
|
||||
from unittest import TestCase
|
||||
from tempfile import mkstemp
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry, Settings
|
||||
from openlp.core.ui import ThemeManager
|
||||
@ -48,9 +48,14 @@ class TestThemeManager(TestCase):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
fd, self.ini_file = mkstemp('.ini')
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
self.fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
Registry.create()
|
||||
self.theme_manager = ThemeManager()
|
||||
|
||||
@ -58,9 +63,8 @@ class TestThemeManager(TestCase):
|
||||
"""
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
os.unlink(self.ini_file)
|
||||
os.close(self.fd)
|
||||
os.unlink(Settings().fileName())
|
||||
del self.app
|
||||
|
||||
def initialise_test(self):
|
||||
"""
|
||||
|
@ -3,6 +3,7 @@ Functional tests to test the AppLocation class and related methods.
|
||||
"""
|
||||
import os
|
||||
from unittest import TestCase
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.utils import is_not_image_file
|
||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||
@ -12,6 +13,17 @@ class TestUtils(TestCase):
|
||||
"""
|
||||
A test suite to test out various methods around the Utils functions.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Some pre-test setup required.
|
||||
"""
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
|
||||
def is_not_image_empty_test(self):
|
||||
"""
|
||||
Test the method handles an empty string
|
||||
@ -49,4 +61,5 @@ class TestUtils(TestCase):
|
||||
result = is_not_image_file(file_name)
|
||||
|
||||
# THEN the result is false
|
||||
assert result is True, 'The file is not an image file so the test should return True'
|
||||
assert result is True, 'The file is not an image file so the test should return True'
|
||||
|
||||
|
@ -49,7 +49,11 @@ class TestEditCustomForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
media_item = MagicMock()
|
||||
@ -62,7 +66,6 @@ class TestEditCustomForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def load_themes_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Module to test the EditCustomSlideForm.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
|
||||
@ -19,7 +19,11 @@ class TestEditCustomSlideForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = EditCustomSlideForm()
|
||||
@ -30,7 +34,6 @@ class TestEditCustomSlideForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def basic_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.authorsform package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.forms.authorsform import AuthorsForm
|
||||
@ -19,7 +19,11 @@ class TestAuthorsForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = AuthorsForm()
|
||||
@ -30,7 +34,6 @@ class TestAuthorsForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.editsongform package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.forms.editsongform import EditSongForm
|
||||
@ -20,7 +20,11 @@ class TestEditSongForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
Registry().register('theme_manager', MagicMock())
|
||||
@ -32,7 +36,6 @@ class TestEditSongForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -19,7 +19,11 @@ class TestEditVerseForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = EditVerseForm()
|
||||
@ -30,7 +34,6 @@ class TestEditVerseForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.topicsform package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.forms.topicsform import TopicsForm
|
||||
@ -19,7 +19,11 @@ class TestTopicsForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
self.app = QtGui.QApplication([])
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
self.main_window = QtGui.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = TopicsForm()
|
||||
@ -30,7 +34,6 @@ class TestTopicsForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user