Initial attempt to move to nose2

This commit is contained in:
Raoul Snyman 2016-05-31 23:40:13 +02:00
parent 65f108de90
commit 672b8334fa
117 changed files with 793 additions and 769 deletions

17
nose2.cfg Normal file
View File

@ -0,0 +1,17 @@
[unittest]
verbose = True
[log-capture]
always-on = True
clear-handlers = True
filter = -nose
log-level = ERROR
[test-result]
always-on = True
descriptions = True
[coverage]
always-on = False
coverage = openlp
coverage-report = html

View File

@ -29,7 +29,7 @@ from tests.helpers.testmixin import TestMixin
class TestInitFunctions(TestMixin, TestCase):
def parse_options_basic_test(self):
def test_parse_options_basic(self):
"""
Test the parse options process works
@ -46,7 +46,7 @@ class TestInitFunctions(TestMixin, TestCase):
self.assertEquals(args.style, None, 'There are no style flags to be processed')
self.assertEquals(args.rargs, [], 'The service file should be blank')
def parse_options_debug_test(self):
def test_parse_options_debug(self):
"""
Test the parse options process works for debug only
@ -63,7 +63,7 @@ class TestInitFunctions(TestMixin, TestCase):
self.assertEquals(args.style, None, 'There are no style flags to be processed')
self.assertEquals(args.rargs, [], 'The service file should be blank')
def parse_options_debug_and_portable_test(self):
def test_parse_options_debug_and_portable(self):
"""
Test the parse options process works for debug and portable
@ -80,7 +80,7 @@ class TestInitFunctions(TestMixin, TestCase):
self.assertEquals(args.style, None, 'There are no style flags to be processed')
self.assertEquals(args.rargs, [], 'The service file should be blank')
def parse_options_all_no_file_test(self):
def test_parse_options_all_no_file(self):
"""
Test the parse options process works with two options
@ -97,7 +97,7 @@ class TestInitFunctions(TestMixin, TestCase):
self.assertEquals(args.style, None, 'There are no style flags to be processed')
self.assertEquals(args.rargs, [], 'The service file should be blank')
def parse_options_file_test(self):
def test_parse_options_file(self):
"""
Test the parse options process works with a file
@ -114,7 +114,7 @@ class TestInitFunctions(TestMixin, TestCase):
self.assertEquals(args.style, None, 'There are no style flags to be processed')
self.assertEquals(args.rargs, 'dummy_temp', 'The service file should not be blank')
def parse_options_file_and_debug_test(self):
def test_parse_options_file_and_debug(self):
"""
Test the parse options process works with a file

View File

@ -49,7 +49,7 @@ class TestCategoryActionList(TestCase):
"""
del self.list
def contains_test(self):
def test_contains(self):
"""
Test the __contains__() method
"""
@ -61,7 +61,7 @@ class TestCategoryActionList(TestCase):
self.assertTrue(self.action1 in self.list)
self.assertFalse(self.action2 in self.list)
def len_test(self):
def test_len(self):
"""
Test the __len__ method
"""
@ -77,7 +77,7 @@ class TestCategoryActionList(TestCase):
# THEN: Check the length.
self.assertEqual(len(self.list), 1, "The length should be 1.")
def append_test(self):
def test_append(self):
"""
Test the append() method
"""
@ -92,7 +92,7 @@ class TestCategoryActionList(TestCase):
self.assertEqual(self.list.actions[0], (0, self.action1))
self.assertEqual(self.list.actions[1], (1, self.action2))
def add_test(self):
def test_add(self):
"""
Test the add() method
"""
@ -111,7 +111,7 @@ class TestCategoryActionList(TestCase):
self.assertEqual(self.list.actions[0], (41, self.action2))
self.assertEqual(self.list.actions[1], (42, self.action1))
def iterator_test(self):
def test_iterator(self):
"""
Test the __iter__ and __next__ methods
"""
@ -126,7 +126,7 @@ class TestCategoryActionList(TestCase):
self.assertIs(l[0], self.action1)
self.assertIs(l[1], self.action2)
def remove_test(self):
def test_remove(self):
"""
Test the remove() method
"""

View File

@ -36,7 +36,7 @@ class TestAppLocation(TestCase):
"""
A test suite to test out various methods around the AppLocation class.
"""
def get_data_path_test(self):
def test_get_data_path(self):
"""
Test the AppLocation.get_data_path() method
"""
@ -60,7 +60,7 @@ class TestAppLocation(TestCase):
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):
def test_get_data_path_with_custom_location(self):
"""
Test the AppLocation.get_data_path() method when a custom location is set in the settings
"""
@ -80,7 +80,7 @@ class TestAppLocation(TestCase):
mocked_settings.value.assert_called_with('advanced/data path')
self.assertEqual('custom/dir', data_path, 'Result should be "custom/dir"')
def get_files_no_section_no_extension_test(self):
def test_get_files_no_section_no_extension(self):
"""
Test the AppLocation.get_files() method with no parameters passed.
"""
@ -96,7 +96,7 @@ class TestAppLocation(TestCase):
# Then: check if the file lists are identical.
self.assertListEqual(FILE_LIST, result, 'The file lists should be identical.')
def get_files_test(self):
def test_get_files(self):
"""
Test the AppLocation.get_files() method with all parameters passed.
"""
@ -115,7 +115,7 @@ class TestAppLocation(TestCase):
# Then: check if the file lists are identical.
self.assertListEqual(['file5.mp3', 'file6.mp3'], result, 'The file lists should be identical.')
def get_section_data_path_test(self):
def test_get_section_data_path(self):
"""
Test the AppLocation.get_section_data_path() method
"""
@ -132,7 +132,7 @@ class TestAppLocation(TestCase):
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):
def test_get_directory_for_app_dir(self):
"""
Test the AppLocation.get_directory() method for AppLocation.AppDir
"""
@ -146,7 +146,7 @@ class TestAppLocation(TestCase):
# THEN: check that the correct directory is returned
self.assertEqual(os.path.join('app', 'dir'), directory, 'Directory should be "app/dir"')
def get_directory_for_plugins_dir_test(self):
def test_get_directory_for_plugins_dir(self):
"""
Test the AppLocation.get_directory() method for AppLocation.PluginsDir
"""
@ -167,7 +167,7 @@ class TestAppLocation(TestCase):
# THEN: The correct directory should be returned
self.assertEqual(os.path.join('plugins', 'dir'), directory, 'Directory should be "plugins/dir"')
def get_frozen_path_in_unfrozen_app_test(self):
def test_get_frozen_path_in_unfrozen_app(self):
"""
Test the _get_frozen_path() function when the application is not frozen (compiled by PyInstaller)
"""
@ -181,7 +181,7 @@ class TestAppLocation(TestCase):
# THEN: The non-frozen parameter is returned
self.assertEqual('not frozen', frozen_path, '_get_frozen_path should return "not frozen"')
def get_frozen_path_in_frozen_app_test(self):
def test_get_frozen_path_in_frozen_app(self):
"""
Test the get_frozen_path() function when the application is frozen (compiled by PyInstaller)
"""

View File

@ -34,7 +34,7 @@ class TestCommonFunctions(TestCase):
"""
A test suite to test out various functions in the openlp.core.common module.
"""
def check_directory_exists_test(self):
def test_check_directory_exists(self):
"""
Test the check_directory_exists() function
"""
@ -73,7 +73,7 @@ class TestCommonFunctions(TestCase):
mocked_exists.assert_called_with(directory_to_check)
self.assertRaises(ValueError, check_directory_exists, directory_to_check)
def de_hump_conversion_test(self):
def test_de_hump_conversion(self):
"""
Test the de_hump function with a class name
"""
@ -86,7 +86,7 @@ class TestCommonFunctions(TestCase):
# THEN: the new string should be converted to python format
self.assertTrue(new_string == "my_class", 'The class name should have been converted')
def de_hump_static_test(self):
def test_de_hump_static(self):
"""
Test the de_hump function with a python string
"""
@ -99,7 +99,7 @@ class TestCommonFunctions(TestCase):
# THEN: the new string should be converted to python format
self.assertTrue(new_string == "my_class", 'The class name should have been preserved')
def trace_error_handler_test(self):
def test_trace_error_handler(self):
"""
Test the trace_error_handler() method
"""
@ -115,7 +115,7 @@ class TestCommonFunctions(TestCase):
mocked_logger.error.assert_called_with(
'OpenLP Error trace\n File openlp.fake at line 56 \n\t called trace_error_handler_test')
def translate_test(self):
def test_translate(self):
"""
Test the translate() function
"""
@ -132,7 +132,7 @@ class TestCommonFunctions(TestCase):
mocked_translate.assert_called_with(context, text, comment)
self.assertEqual('Translated string', result, 'The translated string should have been returned')
def is_win_test(self):
def test_is_win(self):
"""
Test the is_win() function
"""
@ -148,7 +148,7 @@ class TestCommonFunctions(TestCase):
self.assertFalse(is_macosx(), 'is_macosx() should return False')
self.assertFalse(is_linux(), 'is_linux() should return False')
def is_macosx_test(self):
def test_is_macosx(self):
"""
Test the is_macosx() function
"""
@ -164,7 +164,7 @@ class TestCommonFunctions(TestCase):
self.assertFalse(is_win(), 'is_win() should return False')
self.assertFalse(is_linux(), 'is_linux() should return False')
def is_linux_test(self):
def test_is_linux(self):
"""
Test the is_linux() function
"""
@ -180,7 +180,7 @@ class TestCommonFunctions(TestCase):
self.assertFalse(is_win(), 'is_win() should return False')
self.assertFalse(is_macosx(), 'is_macosx() should return False')
def clean_button_text_test(self):
def test_clean_button_text(self):
"""
Test the clean_button_text() function.
"""

View File

@ -67,7 +67,7 @@ class TestUtilsDBFunctions(TestCase):
time.sleep(1)
retries += 1
def delete_column_test(self):
def test_delete_column(self):
"""
Test deleting a single column in a table
"""
@ -85,7 +85,7 @@ class TestUtilsDBFunctions(TestCase):
if column.name == 'song_book_id':
self.fail("The column 'song_book_id' should have been deleted.")
def delete_columns_test(self):
def test_delete_columns(self):
"""
Test deleting multiple columns in a table
"""

View File

@ -48,7 +48,7 @@ class TestInit(TestCase, TestMixin):
"""
self.destroy_settings()
def add_actions_empty_list_test(self):
def test_add_actions_empty_list(self):
"""
Test that no actions are added when the list is empty
"""
@ -63,7 +63,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
def add_actions_none_action_test(self):
def test_add_actions_none_action(self):
"""
Test that a separator is added when a None action is in the list
"""
@ -78,7 +78,7 @@ class TestInit(TestCase, TestMixin):
mocked_target.addSeparator.assert_called_with()
self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
def add_actions_add_action_test(self):
def test_add_actions_add_action(self):
"""
Test that an action is added when a valid action is in the list
"""
@ -93,7 +93,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
mocked_target.addAction.assert_called_with('action')
def add_actions_action_and_none_test(self):
def test_add_actions_action_and_none(self):
"""
Test that an action and a separator are added when a valid action and None are in the list
"""
@ -108,7 +108,7 @@ class TestInit(TestCase, TestMixin):
mocked_target.addSeparator.assert_called_with()
mocked_target.addAction.assert_called_with('action')
def get_uno_instance_pipe_test(self):
def test_get_uno_instance_pipe(self):
"""
Test that when the UNO connection type is "pipe" the resolver is given the "pipe" URI
"""
@ -121,7 +121,7 @@ class TestInit(TestCase, TestMixin):
# THEN: the resolve method is called with the correct argument
mock_resolver.resolve.assert_called_with('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext')
def get_uno_instance_socket_test(self):
def test_get_uno_instance_socket(self):
"""
Test that when the UNO connection type is other than "pipe" the resolver is given the "socket" URI
"""
@ -134,7 +134,7 @@ class TestInit(TestCase, TestMixin):
# THEN: the resolve method is called with the correct argument
mock_resolver.resolve.assert_called_with('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
def get_uno_command_libreoffice_command_exists_test(self):
def test_get_uno_command_libreoffice_command_exists(self):
"""
Test the ``get_uno_command`` function uses the libreoffice command when available.
:return:
@ -151,7 +151,7 @@ class TestInit(TestCase, TestMixin):
'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
' "--accept=pipe,name=openlp_pipe;urp;"')
def get_uno_command_only_soffice_command_exists_test(self):
def test_get_uno_command_only_soffice_command_exists(self):
"""
Test the ``get_uno_command`` function uses the soffice command when the libreoffice command is not available.
:return:
@ -169,7 +169,7 @@ class TestInit(TestCase, TestMixin):
self.assertEquals(result, 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
' "--accept=pipe,name=openlp_pipe;urp;"')
def get_uno_command_when_no_command_exists_test(self):
def test_get_uno_command_when_no_command_exists(self):
"""
Test the ``get_uno_command`` function raises an FileNotFoundError when neither the libreoffice or soffice
commands are available.
@ -183,7 +183,7 @@ class TestInit(TestCase, TestMixin):
# THEN: a FileNotFoundError exception should be raised
self.assertRaises(FileNotFoundError, get_uno_command)
def get_uno_command_connection_type_test(self):
def test_get_uno_command_connection_type(self):
"""
Test the ``get_uno_command`` function when the connection type is anything other than pipe.
:return:
@ -198,7 +198,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
' "--accept=socket,host=localhost,port=2002;urp;"')
def get_filesystem_encoding_sys_function_not_called_test(self):
def test_get_filesystem_encoding_sys_function_not_called(self):
"""
Test the get_filesystem_encoding() function does not call the sys.getdefaultencoding() function
"""
@ -215,7 +215,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(0, mocked_getdefaultencoding.called, 'getdefaultencoding should not have been called')
self.assertEqual('cp1252', result, 'The result should be "cp1252"')
def get_filesystem_encoding_sys_function_is_called_test(self):
def test_get_filesystem_encoding_sys_function_is_called(self):
"""
Test the get_filesystem_encoding() function calls the sys.getdefaultencoding() function
"""
@ -233,7 +233,7 @@ class TestInit(TestCase, TestMixin):
mocked_getdefaultencoding.assert_called_with()
self.assertEqual('utf-8', result, 'The result should be "utf-8"')
def split_filename_with_file_path_test(self):
def test_split_filename_with_file_path(self):
"""
Test the split_filename() function with a path to a file
"""
@ -253,7 +253,7 @@ class TestInit(TestCase, TestMixin):
# THEN: A tuple should be returned.
self.assertEqual(wanted_result, result, 'A tuple with the dir and file name should have been returned')
def split_filename_with_dir_path_test(self):
def test_split_filename_with_dir_path(self):
"""
Test the split_filename() function with a path to a directory
"""
@ -274,7 +274,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(wanted_result, result,
'A two-entry tuple with the directory and file name (empty) should have been returned.')
def clean_filename_test(self):
def test_clean_filename(self):
"""
Test the clean_filename() function
"""
@ -288,7 +288,7 @@ class TestInit(TestCase, TestMixin):
# THEN: The file name should be cleaned.
self.assertEqual(wanted_name, result, 'The file name should not contain any special characters.')
def delete_file_no_path_test(self):
def test_delete_file_no_path(self):
"""
Test the delete_file function when called with out a valid path
"""
@ -299,7 +299,7 @@ class TestInit(TestCase, TestMixin):
# THEN: delete_file should return False
self.assertFalse(result, "delete_file should return False when called with ''")
def delete_file_path_success_test(self):
def test_delete_file_path_success(self):
"""
Test the delete_file function when it successfully deletes a file
"""
@ -312,7 +312,7 @@ class TestInit(TestCase, TestMixin):
# THEN: delete_file should return True
self.assertTrue(result, 'delete_file should return True when it successfully deletes a file')
def delete_file_path_no_file_exists_test(self):
def test_delete_file_path_no_file_exists(self):
"""
Test the delete_file function when the file to remove does not exist
"""
@ -325,7 +325,7 @@ class TestInit(TestCase, TestMixin):
# THEN: delete_file should return True
self.assertTrue(result, 'delete_file should return True when the file doesnt exist')
def delete_file_path_exception_test(self):
def test_delete_file_path_exception(self):
"""
Test the delete_file function when os.remove raises an exception
"""

View File

@ -33,7 +33,7 @@ class TestLanguageManager(TestCase):
A test suite to test out various methods around the common __init__ class.
"""
def get_locale_key_test(self):
def test_get_locale_key(self):
"""
Test the get_locale_key(string) function
"""
@ -50,7 +50,7 @@ class TestLanguageManager(TestCase):
self.assertEqual(['Aushang', '\u00C4u\u00DFerung', 'Auszug'], sorted_list,
'Strings should be sorted properly')
def get_natural_key_test(self):
def test_get_natural_key(self):
"""
Test the get_natural_key(string) function
"""

View File

@ -33,7 +33,7 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..',
class TestRegistry(TestCase):
def registry_service_test(self):
def test_registry_service(self):
"""
Test the registry creation and its usage
"""
@ -65,7 +65,7 @@ class TestRegistry(TestCase):
temp = Registry().get('test1')
self.assertEqual(temp, None, 'None should have been returned for deleted service')
def registry_function_test(self):
def test_registry_function(self):
"""
Test the registry function creation and their usages
"""
@ -93,7 +93,7 @@ class TestRegistry(TestCase):
# THEN: I expect then function to have been called and a return given
self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
def registry_working_flags_test(self):
def test_registry_working_flags(self):
"""
Test the registry working flags creation and its usage
"""
@ -130,7 +130,7 @@ class TestRegistry(TestCase):
self.assertEqual(context.exception.args[0], 'Working Flag test1 not found in list',
'KeyError exception should have been thrown for duplicate working flag')
def remove_function_test(self):
def test_remove_function(self):
"""
Test the remove_function() method
"""

View File

@ -32,7 +32,7 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..',
class TestRegistryMixin(TestCase):
def registry_mixin_missing_test(self):
def test_registry_mixin_missing(self):
"""
Test the registry creation and its usage
"""
@ -45,7 +45,7 @@ class TestRegistryMixin(TestCase):
# THEN: The following methods are missing
self.assertEqual(len(Registry().functions_list), 0), 'The function should not be in the dict anymore.'
def registry_mixin_present_test(self):
def test_registry_mixin_present(self):
"""
Test the registry creation and its usage
"""

View File

@ -39,7 +39,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
"""
Registry.create()
def no_application_test(self):
def test_no_application(self):
"""
Test property if no registry value assigned
"""
@ -48,7 +48,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
# THEN the application should be none
self.assertEqual(self.application, None, 'The application value should be None')
def application_test(self):
def test_application(self):
"""
Test property if registry value assigned
"""
@ -62,7 +62,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
self.assertEqual(self.application, application, 'The application value should match')
@patch('openlp.core.common.registryproperties.is_win')
def application_on_windows_test(self, mocked_is_win):
def test_application_on_windows(self, mocked_is_win):
"""
Test property if registry value assigned on Windows
"""

View File

@ -47,7 +47,7 @@ class TestSettings(TestCase, TestMixin):
"""
self.destroy_settings()
def recent_files_conv_test(self):
def test_recent_files_conv(self):
"""
Test that recent_files_conv, converts various possible types of values correctly.
"""
@ -66,7 +66,7 @@ class TestSettings(TestCase, TestMixin):
# THEN: The actual result should be the same as the expected result
self.assertEqual(actual_result, expected_result)
def settings_basic_test(self):
def test_settings_basic(self):
"""
Test the Settings creation and its default usage
"""
@ -84,7 +84,7 @@ class TestSettings(TestCase, TestMixin):
# THEN the new value is returned when re-read
self.assertTrue(Settings().value('core/has run wizard'), 'The saved value should have been returned')
def settings_override_test(self):
def test_settings_override(self):
"""
Test the Settings creation and its override usage
"""
@ -106,7 +106,7 @@ class TestSettings(TestCase, TestMixin):
# THEN the new value is returned when re-read
self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
def settings_override_with_group_test(self):
def test_settings_override_with_group(self):
"""
Test the Settings creation and its override usage - with groups
"""
@ -130,7 +130,7 @@ class TestSettings(TestCase, TestMixin):
# THEN the new value is returned when re-read
self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
def settings_nonexisting_test(self):
def test_settings_nonexisting(self):
"""
Test the Settings on query for non-existing value
"""
@ -142,7 +142,7 @@ class TestSettings(TestCase, TestMixin):
# THEN: An exception with the non-existing key should be thrown
self.assertEqual(str(cm.exception), "'core/does not exists'", 'We should get an exception')
def extend_default_settings_test(self):
def test_extend_default_settings(self):
"""
Test that the extend_default_settings method extends the default settings
"""

View File

@ -29,7 +29,7 @@ from openlp.core.common import UiStrings
class TestUiStrings(TestCase):
def check_same_instance_test(self):
def test_check_same_instance(self):
"""
Test the UiStrings class - we always should have only one instance of the UiStrings class.
"""

View File

@ -44,7 +44,7 @@ class TestVersionchecker(TestMixin, TestCase):
"""
self.destroy_settings()
def version_thread_triggered_test(self):
def test_version_thread_triggered(self):
"""
Test the version thread call does not trigger UI
:return:

View File

@ -37,7 +37,7 @@ class TestDB(TestCase):
"""
A test case for all the tests for the :mod:`~openlp.core.lib.db` module.
"""
def init_db_calls_correct_functions_test(self):
def test_init_db_calls_correct_functions(self):
"""
Test that the init_db function makes the correct function calls
"""
@ -67,7 +67,7 @@ class TestDB(TestCase):
self.assertIs(session, mocked_scoped_session_object, 'The ``session`` object should be the mock')
self.assertIs(metadata, mocked_metadata, 'The ``metadata`` object should be the mock')
def init_db_defaults_test(self):
def test_init_db_defaults(self):
"""
Test that initialising an in-memory SQLite database via ``init_db`` uses the defaults
"""
@ -81,7 +81,7 @@ class TestDB(TestCase):
self.assertIsInstance(session, ScopedSession, 'The ``session`` object should be a ``ScopedSession`` instance')
self.assertIsInstance(metadata, MetaData, 'The ``metadata`` object should be a ``MetaData`` instance')
def get_upgrade_op_test(self):
def test_get_upgrade_op(self):
"""
Test that the ``get_upgrade_op`` function creates a MigrationContext and an Operations object
"""
@ -105,7 +105,7 @@ class TestDB(TestCase):
MockedMigrationContext.configure.assert_called_with(mocked_connection)
MockedOperations.assert_called_with(mocked_context)
def delete_database_without_db_file_name_test(self):
def test_delete_database_without_db_file_name(self):
"""
Test that the ``delete_database`` function removes a database file, without the file name parameter
"""
@ -125,7 +125,7 @@ class TestDB(TestCase):
mocked_delete_file.assert_called_with(test_location)
self.assertTrue(result, 'The result of delete_file should be True (was rigged that way)')
def delete_database_with_db_file_name_test(self):
def test_delete_database_with_db_file_name(self):
"""
Test that the ``delete_database`` function removes a database file, with the file name supplied
"""

View File

@ -26,7 +26,7 @@ class TestFileDialog(TestCase):
self.qt_gui_patcher.stop()
self.ui_strings_patcher.stop()
def get_open_file_names_canceled_test(self):
def test_get_open_file_names_canceled(self):
"""
Test that FileDialog.getOpenFileNames() returns and empty QStringList when QFileDialog is canceled
(returns an empty QStringList)
@ -45,7 +45,7 @@ class TestFileDialog(TestCase):
'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames '
'is canceled')
def returned_file_list_test(self):
def test_returned_file_list(self):
"""
Test that FileDialog.getOpenFileNames handles a list of files properly when QFileList.getOpenFileNames
returns a good file name, a url encoded file name and a non-existing file

View File

@ -47,7 +47,7 @@ class TestFormattingTags(TestCase):
"""
FormattingTags.html_expands = []
def get_html_tags_no_user_tags_test(self):
def test_get_html_tags_no_user_tags(self):
"""
Test the FormattingTags class' get_html_tags static method.
"""
@ -68,7 +68,7 @@ class TestFormattingTags(TestCase):
# THEN: Lists should be identical.
assert old_tags_list == new_tags_list, 'The formatting tag lists should be identical.'
def get_html_tags_with_user_tags_test(self):
def test_get_html_tags_with_user_tags(self):
"""
FormattingTags class - test the get_html_tags(), add_html_tags() and remove_html_tag() methods.
"""

View File

@ -216,7 +216,7 @@ class Htmbuilder(TestCase, TestMixin):
"""
self.destroy_settings()
def build_html_test(self):
def test_build_html(self):
"""
Test the build_html() function
"""
@ -246,7 +246,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: The returned html should match.
self.assertEqual(html, HTML, 'The returned html should match')
def build_background_css_radial_test(self):
def test_build_background_css_radial(self):
"""
Test the build_background_css() function with a radial background
"""
@ -262,7 +262,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: The returned css should match.
self.assertEqual(BACKGROUND_CSS_RADIAL, css, 'The background css should be equal.')
def build_lyrics_css_test(self):
def test_build_lyrics_css(self):
"""
Test the build_lyrics_css() function
"""
@ -283,7 +283,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: The css should be equal.
self.assertEqual(LYRICS_CSS, css, 'The lyrics css should be equal.')
def build_lyrics_outline_css_test(self):
def test_build_lyrics_outline_css(self):
"""
Test the build_lyrics_outline_css() function
"""
@ -300,7 +300,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: The css should be equal.
self.assertEqual(LYRICS_OUTLINE_CSS, css, 'The outline css should be equal.')
def build_lyrics_format_css_test(self):
def test_build_lyrics_format_css(self):
"""
Test the build_lyrics_format_css() function
"""
@ -323,7 +323,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: They should be equal.
self.assertEqual(LYRICS_FORMAT_CSS, css, 'The lyrics format css should be equal.')
def build_footer_css_test(self):
def test_build_footer_css(self):
"""
Test the build_footer_css() function
"""
@ -341,7 +341,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: THE css should be the same.
self.assertEqual(FOOTER_CSS, css, 'The footer strings should be equal.')
def build_footer_css_wrap_test(self):
def test_build_footer_css_wrap(self):
"""
Test the build_footer_css() function
"""
@ -360,7 +360,7 @@ class Htmbuilder(TestCase, TestMixin):
# THEN: Footer should wrap
self.assertEqual(FOOTER_CSS_WRAP, css, 'The footer strings should be equal.')
def build_footer_invalid_test(self):
def test_build_footer_invalid(self):
"""
Test the build_footer_css() function
"""
@ -381,7 +381,7 @@ class Htmbuilder(TestCase, TestMixin):
self.assertEqual(FOOTER_CSS_INVALID, css[0], 'The footer strings should be blank.')
self.assertEqual(FOOTER_CSS_INVALID, css[1], 'The footer strings should be blank.')
def webkit_version_test(self):
def test_webkit_version(self):
"""
Test the webkit_version() function
"""

View File

@ -57,7 +57,7 @@ class TestImageManager(TestCase, TestMixin):
"""
del self.app
def basic_image_manager_test(self):
def test_basic_image_manager(self):
"""
Test the Image Manager setup basic functionality
"""
@ -83,7 +83,7 @@ class TestImageManager(TestCase, TestMixin):
self.image_manager.get_image(TEST_PATH, 'church1.jpg')
self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing image')
def different_dimension_image_test(self):
def test_different_dimension_image(self):
"""
Test the Image Manager with dimensions
"""
@ -115,7 +115,7 @@ class TestImageManager(TestCase, TestMixin):
self.image_manager.get_image(full_path, 'church.jpg', 120, 120)
self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing dimension')
def process_cache_test(self):
def test_process_cache(self):
"""
Test the process_cache method
"""

View File

@ -38,7 +38,7 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..',
class TestLib(TestCase):
def str_to_bool_with_bool_true_test(self):
def test_str_to_bool_with_bool_true(self):
"""
Test the str_to_bool function with boolean input of True
"""
@ -52,7 +52,7 @@ class TestLib(TestCase):
self.assertIsInstance(true_result, bool, 'The result should be a boolean')
self.assertTrue(true_result, 'The result should be True')
def str_to_bool_with_bool_false_test(self):
def test_str_to_bool_with_bool_false(self):
"""
Test the str_to_bool function with boolean input of False
"""
@ -66,7 +66,7 @@ class TestLib(TestCase):
self.assertIsInstance(false_result, bool, 'The result should be a boolean')
self.assertFalse(false_result, 'The result should be True')
def str_to_bool_with_integer_test(self):
def test_str_to_bool_with_integer(self):
"""
Test the str_to_bool function with an integer input
"""
@ -79,7 +79,7 @@ class TestLib(TestCase):
# THEN: we should get back a false
self.assertFalse(int_result, 'The result should be False')
def str_to_bool_with_invalid_string_test(self):
def test_str_to_bool_with_invalid_string(self):
"""
Test the str_to_bool function with an invalid string
"""
@ -92,7 +92,7 @@ class TestLib(TestCase):
# THEN: we should get back a false
self.assertFalse(str_result, 'The result should be False')
def str_to_bool_with_string_false_test(self):
def test_str_to_bool_with_string_false(self):
"""
Test the str_to_bool function with a string saying "false"
"""
@ -105,7 +105,7 @@ class TestLib(TestCase):
# THEN: we should get back a false
self.assertFalse(false_result, 'The result should be False')
def str_to_bool_with_string_no_test(self):
def test_str_to_bool_with_string_no(self):
"""
Test the str_to_bool function with a string saying "NO"
"""
@ -118,7 +118,7 @@ class TestLib(TestCase):
# THEN: we should get back a false
self.assertFalse(str_result, 'The result should be False')
def str_to_bool_with_true_string_value_test(self):
def test_str_to_bool_with_true_string_value(self):
"""
Test the str_to_bool function with a string set to "True"
"""
@ -131,7 +131,7 @@ class TestLib(TestCase):
# THEN: we should get back a true
self.assertTrue(true_result, 'The result should be True')
def str_to_bool_with_yes_string_value_test(self):
def test_str_to_bool_with_yes_string_value(self):
"""
Test the str_to_bool function with a string set to "yes"
"""
@ -144,7 +144,7 @@ class TestLib(TestCase):
# THEN: we should get back a true
self.assertTrue(str_result, 'The result should be True')
def get_text_file_string_no_file_test(self):
def test_get_text_file_string_no_file(self):
"""
Test the get_text_file_string() function when a file does not exist
"""
@ -160,7 +160,7 @@ class TestLib(TestCase):
mocked_isfile.assert_called_with(filename)
self.assertFalse(result, 'False should be returned if no file exists')
def get_text_file_string_read_error_test(self):
def test_get_text_file_string_read_error(self):
"""
Test the get_text_file_string() method when a read error happens
"""
@ -179,13 +179,13 @@ class TestLib(TestCase):
mocked_open.assert_called_with(filename, 'r', encoding='utf-8')
self.assertIsNone(result, 'None should be returned if the file cannot be opened')
def get_text_file_string_decode_error_test(self):
def test_get_text_file_string_decode_error(self):
"""
Test the get_text_file_string() method when the contents cannot be decoded
"""
self.skipTest('Impossible to test due to conflicts when mocking out the "open" function')
def build_icon_with_qicon_test(self):
def test_build_icon_with_qicon(self):
"""
Test the build_icon() function with a QIcon instance
"""
@ -200,7 +200,7 @@ class TestLib(TestCase):
# THEN: The result should be our mocked QIcon
self.assertIs(mocked_icon, result, 'The result should be the mocked QIcon')
def build_icon_with_resource_test(self):
def test_build_icon_with_resource(self):
"""
Test the build_icon() function with a resource URI
"""
@ -222,7 +222,7 @@ class TestLib(TestCase):
# best we can do is to assert that we get back a MagicMock object.
self.assertIsInstance(result, MagicMock, 'The result should be a MagicMock, because we mocked it out')
def image_to_byte_test(self):
def test_image_to_byte(self):
"""
Test the image_to_byte() function
"""
@ -248,7 +248,7 @@ class TestLib(TestCase):
self.assertEqual('base64mock', result, 'The result should be the return value of the mocked out '
'base64 method')
def create_thumb_with_size_test(self):
def test_create_thumb_with_size(self):
"""
Test the create_thumb() function with a given size.
"""
@ -282,7 +282,7 @@ class TestLib(TestCase):
except:
pass
def create_thumb_no_size_test(self):
def test_create_thumb_no_size(self):
"""
Test the create_thumb() function with no size specified.
"""
@ -316,7 +316,7 @@ class TestLib(TestCase):
except:
pass
def create_thumb_invalid_size_test(self):
def test_create_thumb_invalid_size(self):
"""
Test the create_thumb() function with invalid size specified.
"""
@ -351,7 +351,7 @@ class TestLib(TestCase):
except:
pass
def create_thumb_width_only_test(self):
def test_create_thumb_width_only(self):
"""
Test the create_thumb() function with a size of only width specified.
"""
@ -386,7 +386,7 @@ class TestLib(TestCase):
except:
pass
def create_thumb_height_only_test(self):
def test_create_thumb_height_only(self):
"""
Test the create_thumb() function with a size of only height specified.
"""
@ -421,7 +421,7 @@ class TestLib(TestCase):
except:
pass
def create_thumb_empty_img_test(self):
def test_create_thumb_empty_img(self):
"""
Test the create_thumb() function with a size of only height specified.
"""
@ -469,7 +469,7 @@ class TestLib(TestCase):
except:
pass
def check_item_selected_true_test(self):
def test_check_item_selected_true(self):
"""
Test that the check_item_selected() function returns True when there are selected indexes
"""
@ -486,7 +486,7 @@ class TestLib(TestCase):
mocked_list_widget.selectedIndexes.assert_called_with()
self.assertTrue(result, 'The result should be True')
def check_item_selected_false_test(self):
def test_check_item_selected_false(self):
"""
Test that the check_item_selected() function returns False when there are no selected indexes.
"""
@ -507,7 +507,7 @@ class TestLib(TestCase):
MockedQtWidgets.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message')
self.assertFalse(result, 'The result should be False')
def clean_tags_test(self):
def test_clean_tags(self):
"""
Test clean_tags() method.
"""
@ -529,7 +529,7 @@ class TestLib(TestCase):
# THEN: The strings should be identical.
self.assertEqual(wanted_string, result_string, 'The strings should be identical')
def expand_tags_test(self):
def test_expand_tags(self):
"""
Test the expand_tags() method.
"""
@ -568,7 +568,7 @@ class TestLib(TestCase):
# THEN: The strings should be identical.
self.assertEqual(wanted_string, result_string, 'The strings should be identical.')
def validate_thumb_file_does_not_exist_test(self):
def test_validate_thumb_file_does_not_exist(self):
"""
Test the validate_thumb() function when the thumbnail does not exist
"""
@ -585,7 +585,7 @@ class TestLib(TestCase):
mocked_os.path.exists.assert_called_with(thumb_path)
assert result is False, 'The result should be False'
def validate_thumb_file_exists_and_newer_test(self):
def test_validate_thumb_file_exists_and_newer(self):
"""
Test the validate_thumb() function when the thumbnail exists and has a newer timestamp than the file
"""
@ -605,7 +605,7 @@ class TestLib(TestCase):
# THEN: we should have called a few functions, and the result should be True
# mocked_os.path.exists.assert_called_with(thumb_path)
def validate_thumb_file_exists_and_older_test(self):
def test_validate_thumb_file_exists_and_older(self):
"""
Test the validate_thumb() function when the thumbnail exists but is older than the file
"""
@ -629,7 +629,7 @@ class TestLib(TestCase):
mocked_os.stat.assert_any_call(thumb_path)
assert result is False, 'The result should be False'
def resize_thumb_test(self):
def test_resize_thumb(self):
"""
Test the resize_thumb() function
"""
@ -650,7 +650,7 @@ class TestLib(TestCase):
self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.')
self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.')
def create_separated_list_qlocate_test(self):
def test_create_separated_list_qlocate(self):
"""
Test the create_separated_list function using the Qt provided method
"""
@ -669,7 +669,7 @@ class TestLib(TestCase):
assert string_result == 'Author 1, Author 2, and Author 3', 'The string should be u\'Author 1, ' \
'Author 2, and Author 3\'.'
def create_separated_list_empty_list_test(self):
def test_create_separated_list_empty_list(self):
"""
Test the create_separated_list function with an empty list
"""
@ -685,7 +685,7 @@ class TestLib(TestCase):
# THEN: We shoud have an emptry string.
assert string_result == '', 'The string sould be empty.'
def create_separated_list_with_one_item_test(self):
def test_create_separated_list_with_one_item(self):
"""
Test the create_separated_list function with a list consisting of only one entry
"""
@ -701,7 +701,7 @@ class TestLib(TestCase):
# THEN: We should have "Author 1"
assert string_result == 'Author 1', 'The string should be u\'Author 1\'.'
def create_separated_list_with_two_items_test(self):
def test_create_separated_list_with_two_items(self):
"""
Test the create_separated_list function with a list of two entries
"""
@ -718,7 +718,7 @@ class TestLib(TestCase):
# THEN: We should have "Author 1 and Author 2"
assert string_result == 'Author 1 and Author 2', 'The string should be u\'Author 1 and Author 2\'.'
def create_separated_list_with_three_items_test(self):
def test_create_separated_list_with_three_items(self):
"""
Test the create_separated_list function with a list of three items
"""

View File

@ -44,7 +44,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
@patch(u'openlp.core.lib.mediamanageritem.Settings')
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
def on_double_clicked_test(self, mocked_on_preview_click, MockedSettings):
def test_on_double_clicked(self, mocked_on_preview_click, MockedSettings):
"""
Test that when an item is double-clicked then the item is previewed
"""
@ -60,7 +60,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
# THEN: on_preview_click() should have been called
mocked_on_preview_click.assert_called_with()
def required_icons_test(self):
def test_required_icons(self):
"""
Test the default icons for plugins
"""
@ -77,7 +77,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
@patch(u'openlp.core.lib.mediamanageritem.Settings')
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
def on_double_clicked_go_live_test(self, mocked_on_live_click, MockedSettings):
def test_on_double_clicked_go_live(self, mocked_on_live_click, MockedSettings):
"""
Test that when "Double-click to go live" is enabled that the item goes live
"""
@ -96,7 +96,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
@patch(u'openlp.core.lib.mediamanageritem.Settings')
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
def on_double_clicked_single_click_preview_test(self, mocked_on_preview_click, mocked_on_live_click,
def test_on_double_clicked_single_click_preview(self, mocked_on_preview_click, mocked_on_live_click,
MockedSettings):
"""
Test that when "Single-click preview" is enabled then nothing happens on double-click

View File

@ -49,7 +49,7 @@ class TestPluginManager(TestCase):
Registry().register('main_window', self.mocked_main_window)
Registry().register('settings_form', self.mocked_settings_form)
def hook_media_manager_with_disabled_plugin_test(self):
def test_hook_media_manager_with_disabled_plugin(self):
"""
Test running the hook_media_manager() method with a disabled plugin
"""
@ -66,7 +66,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
'The create_media_manager_item() method should not have been called.')
def hook_media_manager_with_active_plugin_test(self):
def test_hook_media_manager_with_active_plugin(self):
"""
Test running the hook_media_manager() method with an active plugin
"""
@ -82,7 +82,7 @@ class TestPluginManager(TestCase):
# THEN: The create_media_manager_item() method should have been called
mocked_plugin.create_media_manager_item.assert_called_with()
def hook_settings_tabs_with_disabled_plugin_and_no_form_test(self):
def test_hook_settings_tabs_with_disabled_plugin_and_no_form(self):
"""
Test running the hook_settings_tabs() method with a disabled plugin and no form
"""
@ -99,7 +99,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
'The create_media_manager_item() method should not have been called.')
def hook_settings_tabs_with_disabled_plugin_and_mocked_form_test(self):
def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
"""
Test running the hook_settings_tabs() method with a disabled plugin and a mocked form
"""
@ -121,7 +121,7 @@ class TestPluginManager(TestCase):
self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins,
'The plugins on the settings form should be the same as the plugins in the plugin manager')
def hook_settings_tabs_with_active_plugin_and_mocked_form_test(self):
def test_hook_settings_tabs_with_active_plugin_and_mocked_form(self):
"""
Test running the hook_settings_tabs() method with an active plugin and a mocked settings form
"""
@ -143,7 +143,7 @@ class TestPluginManager(TestCase):
self.assertEqual(plugin_manager.plugins, mocked_settings_form.plugin_manager.plugins,
'The plugins on the settings form should be the same as the plugins in the plugin manager')
def hook_settings_tabs_with_active_plugin_and_no_form_test(self):
def test_hook_settings_tabs_with_active_plugin_and_no_form(self):
"""
Test running the hook_settings_tabs() method with an active plugin and no settings form
"""
@ -159,7 +159,7 @@ class TestPluginManager(TestCase):
# THEN: The create_settings_tab() method should have been called
mocked_plugin.create_settings_tab.assert_called_with(self.mocked_settings_form)
def hook_import_menu_with_disabled_plugin_test(self):
def test_hook_import_menu_with_disabled_plugin(self):
"""
Test running the hook_import_menu() method with a disabled plugin
"""
@ -176,7 +176,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.add_import_menu_item.call_count,
'The add_import_menu_item() method should not have been called.')
def hook_import_menu_with_active_plugin_test(self):
def test_hook_import_menu_with_active_plugin(self):
"""
Test running the hook_import_menu() method with an active plugin
"""
@ -192,7 +192,7 @@ class TestPluginManager(TestCase):
# THEN: The add_import_menu_item() method should have been called
mocked_plugin.add_import_menu_item.assert_called_with(self.mocked_main_window.file_import_menu)
def hook_export_menu_with_disabled_plugin_test(self):
def test_hook_export_menu_with_disabled_plugin(self):
"""
Test running the hook_export_menu() method with a disabled plugin
"""
@ -209,7 +209,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.add_export_menu_item.call_count,
'The add_export_menu_item() method should not have been called.')
def hook_export_menu_with_active_plugin_test(self):
def test_hook_export_menu_with_active_plugin(self):
"""
Test running the hook_export_menu() method with an active plugin
"""
@ -225,7 +225,7 @@ class TestPluginManager(TestCase):
# THEN: The add_export_menu_item() method should have been called
mocked_plugin.add_export_menu_item.assert_called_with(self.mocked_main_window.file_export_menu)
def hook_upgrade_plugin_settings_with_disabled_plugin_test(self):
def test_hook_upgrade_plugin_settings_with_disabled_plugin(self):
"""
Test running the hook_upgrade_plugin_settings() method with a disabled plugin
"""
@ -243,7 +243,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.upgrade_settings.call_count,
'The upgrade_settings() method should not have been called.')
def hook_upgrade_plugin_settings_with_active_plugin_test(self):
def test_hook_upgrade_plugin_settings_with_active_plugin(self):
"""
Test running the hook_upgrade_plugin_settings() method with an active plugin
"""
@ -260,7 +260,7 @@ class TestPluginManager(TestCase):
# THEN: The add_export_menu_item() method should have been called
mocked_plugin.upgrade_settings.assert_called_with(settings)
def hook_tools_menu_with_disabled_plugin_test(self):
def test_hook_tools_menu_with_disabled_plugin(self):
"""
Test running the hook_tools_menu() method with a disabled plugin
"""
@ -277,7 +277,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.add_tools_menu_item.call_count,
'The add_tools_menu_item() method should not have been called.')
def hook_tools_menu_with_active_plugin_test(self):
def test_hook_tools_menu_with_active_plugin(self):
"""
Test running the hook_tools_menu() method with an active plugin
"""
@ -293,7 +293,7 @@ class TestPluginManager(TestCase):
# THEN: The add_tools_menu_item() method should have been called
mocked_plugin.add_tools_menu_item.assert_called_with(self.mocked_main_window.tools_menu)
def initialise_plugins_with_disabled_plugin_test(self):
def test_initialise_plugins_with_disabled_plugin(self):
"""
Test running the initialise_plugins() method with a disabled plugin
"""
@ -311,7 +311,7 @@ class TestPluginManager(TestCase):
mocked_plugin.is_active.assert_called_with()
self.assertEqual(0, mocked_plugin.initialise.call_count, 'The initialise() method should not have been called.')
def initialise_plugins_with_active_plugin_test(self):
def test_initialise_plugins_with_active_plugin(self):
"""
Test running the initialise_plugins() method with an active plugin
"""
@ -329,7 +329,7 @@ class TestPluginManager(TestCase):
mocked_plugin.is_active.assert_called_with()
mocked_plugin.initialise.assert_called_with()
def finalise_plugins_with_disabled_plugin_test(self):
def test_finalise_plugins_with_disabled_plugin(self):
"""
Test running the finalise_plugins() method with a disabled plugin
"""
@ -347,7 +347,7 @@ class TestPluginManager(TestCase):
mocked_plugin.is_active.assert_called_with()
self.assertEqual(0, mocked_plugin.finalise.call_count, 'The finalise() method should not have been called.')
def finalise_plugins_with_active_plugin_test(self):
def test_finalise_plugins_with_active_plugin(self):
"""
Test running the finalise_plugins() method with an active plugin
"""
@ -365,7 +365,7 @@ class TestPluginManager(TestCase):
mocked_plugin.is_active.assert_called_with()
mocked_plugin.finalise.assert_called_with()
def get_plugin_by_name_does_not_exist_test(self):
def test_get_plugin_by_name_does_not_exist(self):
"""
Test running the get_plugin_by_name() method to find a plugin that does not exist
"""
@ -381,7 +381,7 @@ class TestPluginManager(TestCase):
# THEN: The is_active() and finalise() methods should have been called
self.assertIsNone(result, 'The result for get_plugin_by_name should be None')
def get_plugin_by_name_exists_test(self):
def test_get_plugin_by_name_exists(self):
"""
Test running the get_plugin_by_name() method to find a plugin that exists
"""
@ -397,7 +397,7 @@ class TestPluginManager(TestCase):
# THEN: The is_active() and finalise() methods should have been called
self.assertEqual(result, mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin')
def new_service_created_with_disabled_plugin_test(self):
def test_new_service_created_with_disabled_plugin(self):
"""
Test running the new_service_created() method with a disabled plugin
"""
@ -416,7 +416,7 @@ class TestPluginManager(TestCase):
self.assertEqual(0, mocked_plugin.new_service_created.call_count,
'The new_service_created() method should not have been called.')
def new_service_created_with_active_plugin_test(self):
def test_new_service_created_with_active_plugin(self):
"""
Test running the new_service_created() method with an active plugin
"""

View File

@ -57,7 +57,7 @@ class TestPJLink(TestCase):
@patch.object(pjlink_test, 'send_command')
@patch.object(pjlink_test, 'waitForReadyRead')
@patch('openlp.core.common.qmd5_hash')
def authenticated_connection_call_test(self, mock_qmd5_hash, mock_waitForReadyRead, mock_send_command,
def test_authenticated_connection_call(self, mock_qmd5_hash, mock_waitForReadyRead, mock_send_command,
mock_readyRead):
"""
Ticket 92187: Fix for projector connect with PJLink authentication exception.
@ -74,7 +74,7 @@ class TestPJLink(TestCase):
self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN,
"Connection request should have been called with TEST_PIN"))
def projector_class_test(self):
def test_projector_class(self):
"""
Test class version from projector
"""
@ -88,7 +88,7 @@ class TestPJLink(TestCase):
self.assertEquals(pjlink.pjlink_class, '1',
'Projector should have returned class=1')
def non_standard_class_reply_test(self):
def test_non_standard_class_reply(self):
"""
Bugfix 1550891: CLSS request returns non-standard 'Class N' reply
"""
@ -103,7 +103,7 @@ class TestPJLink(TestCase):
'Non-standard class reply should have set proper class')
@patch.object(pjlink_test, 'change_status')
def status_change_test(self, mock_change_status):
def test_status_change(self, mock_change_status):
"""
Test process_command call with ERR2 (Parameter) status
"""
@ -120,7 +120,7 @@ class TestPJLink(TestCase):
ERROR_STRING[E_PARAMETER]))
@patch.object(pjlink_test, 'process_inpt')
def projector_return_ok_test(self, mock_process_inpt):
def test_projector_return_ok(self, mock_process_inpt):
"""
Test projector calls process_inpt command when process_command is called with INPT option
"""
@ -135,7 +135,7 @@ class TestPJLink(TestCase):
"process_inpt should have been called with 31")
@patch.object(pjlink_test, 'projectorReceivedData')
def projector_process_lamp_test(self, mock_projectorReceivedData):
def test_projector_process_lamp(self, mock_projectorReceivedData):
"""
Test status lamp on/off and hours
"""
@ -152,7 +152,7 @@ class TestPJLink(TestCase):
'Lamp hours should have been set to 22222')
@patch.object(pjlink_test, 'projectorReceivedData')
def projector_process_multiple_lamp_test(self, mock_projectorReceivedData):
def test_projector_process_multiple_lamp(self, mock_projectorReceivedData):
"""
Test status multiple lamp on/off and hours
"""
@ -179,7 +179,7 @@ class TestPJLink(TestCase):
'Lamp 3 hours should have been set to 33333')
@patch.object(pjlink_test, 'projectorReceivedData')
def projector_process_power_on_test(self, mock_projectorReceivedData):
def test_projector_process_power_on(self, mock_projectorReceivedData):
"""
Test status power to ON
"""
@ -194,7 +194,7 @@ class TestPJLink(TestCase):
self.assertEquals(pjlink.power, S_ON, 'Power should have been set to ON')
@patch.object(pjlink_test, 'projectorReceivedData')
def projector_process_power_off_test(self, mock_projectorReceivedData):
def test_projector_process_power_off(self, mock_projectorReceivedData):
"""
Test status power to STANDBY
"""
@ -209,7 +209,7 @@ class TestPJLink(TestCase):
self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY')
@patch.object(pjlink_test, 'projectorUpdateIcons')
def projector_process_avmt_closed_unmuted_test(self, mock_projectorReceivedData):
def test_projector_process_avmt_closed_unmuted(self, mock_projectorReceivedData):
"""
Test avmt status shutter closed and audio muted
"""
@ -226,7 +226,7 @@ class TestPJLink(TestCase):
self.assertFalse(pjlink.mute, 'Audio should be off')
@patch.object(pjlink_test, 'projectorUpdateIcons')
def projector_process_avmt_open_muted_test(self, mock_projectorReceivedData):
def test_projector_process_avmt_open_muted(self, mock_projectorReceivedData):
"""
Test avmt status shutter open and mute on
"""
@ -243,7 +243,7 @@ class TestPJLink(TestCase):
self.assertTrue(pjlink.mute, 'Audio should be off')
@patch.object(pjlink_test, 'projectorUpdateIcons')
def projector_process_avmt_open_unmuted_test(self, mock_projectorReceivedData):
def test_projector_process_avmt_open_unmuted(self, mock_projectorReceivedData):
"""
Test avmt status shutter open and mute off off
"""
@ -260,7 +260,7 @@ class TestPJLink(TestCase):
self.assertFalse(pjlink.mute, 'Audio should be on')
@patch.object(pjlink_test, 'projectorUpdateIcons')
def projector_process_avmt_closed_muted_test(self, mock_projectorReceivedData):
def test_projector_process_avmt_closed_muted(self, mock_projectorReceivedData):
"""
Test avmt status shutter closed and mute off
"""
@ -276,7 +276,7 @@ class TestPJLink(TestCase):
self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed')
self.assertTrue(pjlink.mute, 'Audio should be on')
def projector_process_input_test(self):
def test_projector_process_input(self):
"""
Test input source status shows current input
"""
@ -290,7 +290,7 @@ class TestPJLink(TestCase):
# THEN: Input selected should reflect current input
self.assertEquals(pjlink.source, '1', 'Input source should be set to "1"')
def projector_reset_information_test(self):
def test_projector_reset_information(self):
"""
Test reset_information() resets all information and stops timers
"""

View File

@ -107,7 +107,7 @@ class TestProjectorDB(TestCase):
time.sleep(1)
retries += 1
def find_record_by_ip_test(self):
def test_find_record_by_ip(self):
"""
Test find record by IP
"""
@ -121,7 +121,7 @@ class TestProjectorDB(TestCase):
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
'Record found should have been test_2 data')
def find_record_by_name_test(self):
def test_find_record_by_name(self):
"""
Test find record by name
"""
@ -135,7 +135,7 @@ class TestProjectorDB(TestCase):
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
'Record found should have been test_2 data')
def record_delete_test(self):
def test_record_delete(self):
"""
Test record can be deleted
"""
@ -150,7 +150,7 @@ class TestProjectorDB(TestCase):
found = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
self.assertFalse(found, 'test_3 record should have been deleted')
def record_edit_test(self):
def test_record_edit(self):
"""
Test edited record returns the same record ID with different data
"""
@ -176,7 +176,7 @@ class TestProjectorDB(TestCase):
self.assertEqual(record_id, record.id, 'Edited record should have the same ID')
self.assertTrue(compare_data(Projector(**TEST3_DATA), record), 'Edited record should have new data')
def source_add_test(self):
def test_source_add(self):
"""
Test source entry for projector item
"""
@ -194,7 +194,7 @@ class TestProjectorDB(TestCase):
item = self.projector.get_projector_by_id(item_id)
self.assertTrue(compare_source(item.source_list[0], source))
def manufacturer_repr_test(self):
def test_manufacturer_repr(self):
"""
Test Manufacturer.__repr__ text
"""
@ -208,7 +208,7 @@ class TestProjectorDB(TestCase):
self.assertEqual(str(manufacturer), '<Manufacturer(name="OpenLP Test")>',
'Manufacturer.__repr__() should have returned a proper representation string')
def model_repr_test(self):
def test_model_repr(self):
"""
Test Model.__repr__ text
"""
@ -222,7 +222,7 @@ class TestProjectorDB(TestCase):
self.assertEqual(str(model), '<Model(name='"OpenLP Test"')>',
'Model.__repr__() should have returned a proper representation string')
def source_repr_test(self):
def test_source_repr(self):
"""
Test Source.__repr__ text
"""
@ -238,7 +238,7 @@ class TestProjectorDB(TestCase):
self.assertEqual(str(source), '<Source(pjlink_name="Test object", pjlink_code="11", text="Input text")>',
'Source.__repr__() should have returned a proper representation string')
def projector_repr_test(self):
def test_projector_repr(self):
"""
Test Projector.__repr__() text
"""
@ -266,7 +266,7 @@ class TestProjectorDB(TestCase):
'source_list="[]") >',
'Projector.__repr__() should have returned a proper representation string')
def projectorsource_repr_test(self):
def test_projectorsource_repr(self):
"""
Test ProjectorSource.__repr__() text
"""

View File

@ -59,7 +59,7 @@ class TestRenderer(TestCase):
"""
del self.screens
def default_screen_layout_test(self):
def test_default_screen_layout(self):
"""
Test the default layout calculations
"""
@ -73,7 +73,7 @@ class TestRenderer(TestCase):
self.assertEqual(renderer.footer_start, 691, 'The base renderer should be a live controller')
@patch('openlp.core.lib.renderer.FormattingTags.get_html_tags')
def get_start_tags_test(self, mocked_get_html_tags):
def test_get_start_tags(self, mocked_get_html_tags):
"""
Test the get_start_tags() method
"""
@ -95,7 +95,7 @@ class TestRenderer(TestCase):
self.assertEqual(result, expected_tuple), 'A tuple should be returned containing the text with correct ' \
'tags, the opening tags, and the opening html tags.'
def word_split_test(self):
def test_word_split(self):
"""
Test the word_split() method
"""
@ -109,7 +109,7 @@ class TestRenderer(TestCase):
# THEN: The word lists should be the same.
self.assertListEqual(result_words, expected_words)
def format_slide_logical_split_test(self):
def test_format_slide_logical_split(self):
"""
Test that a line with text and a logic break does not break the renderer just returns the input
"""
@ -126,7 +126,7 @@ class TestRenderer(TestCase):
# THEN: The word lists should be the same.
self.assertListEqual(result_words, expected_words)
def format_slide_blank_before_split_test(self):
def test_format_slide_blank_before_split(self):
"""
Test that a line with blanks before the logical split at handled
"""
@ -143,7 +143,7 @@ class TestRenderer(TestCase):
# THEN: The blanks have been removed.
self.assertListEqual(result_words, expected_words)
def format_slide_blank_after_split_test(self):
def test_format_slide_blank_after_split(self):
"""
Test that a line with blanks before the logical split at handled
"""

View File

@ -62,7 +62,7 @@ class TestScreenList(TestCase):
del self.screens
del self.application
def add_desktop_test(self):
def test_add_desktop(self):
"""
Test the ScreenList.screen_count_changed method to check if new monitors are detected by OpenLP.
"""

View File

@ -54,7 +54,7 @@ class TestServiceItem(TestCase):
Registry().register('renderer', mocked_renderer)
Registry().register('image_manager', MagicMock())
def service_item_basic_test(self):
def test_service_item_basic(self):
"""
Test the Service Item - basic test
"""
@ -67,7 +67,7 @@ class TestServiceItem(TestCase):
self.assertTrue(service_item.is_valid, 'The new service item should be valid')
self.assertTrue(service_item.missing_frames(), 'There should not be any frames in the service item')
def service_item_load_custom_from_service_test(self):
def test_service_item_load_custom_from_service(self):
"""
Test the Service Item - adding a custom slide from a saved service
"""
@ -97,7 +97,7 @@ class TestServiceItem(TestCase):
self.assertEqual('Slide 2', service_item.get_frame_title(1), '"Slide 2" has been returned as the title')
self.assertEqual('', service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3')
def service_item_load_image_from_service_test(self):
def test_service_item_load_image_from_service(self):
"""
Test the Service Item - adding an image from a saved service
"""
@ -141,7 +141,7 @@ class TestServiceItem(TestCase):
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
'This service item should be able to have new items added to it')
def service_item_load_image_from_local_service_test(self):
def test_service_item_load_image_from_local_service(self):
"""
Test the Service Item - adding an image from a saved local service
"""
@ -206,7 +206,7 @@ class TestServiceItem(TestCase):
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
'This service item should be able to have new items added to it')
def add_from_command_for_a_presentation_test(self):
def test_add_from_command_for_a_presentation(self):
"""
Test the Service Item - adding a presentation
"""
@ -226,7 +226,7 @@ class TestServiceItem(TestCase):
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
def add_from_comamnd_without_display_title_and_notes_test(self):
def test_add_from_comamnd_without_display_title_and_notes(self):
"""
Test the Service Item - add from command, but not presentation
"""
@ -246,7 +246,7 @@ class TestServiceItem(TestCase):
@patch(u'openlp.core.lib.serviceitem.ServiceItem.image_manager')
@patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path')
def add_from_command_for_a_presentation_thumb_test(self, mocked_get_section_data_path, mocked_image_manager):
def test_add_from_command_for_a_presentation_thumb(self, mocked_get_section_data_path, mocked_image_manager):
"""
Test the Service Item - adding a presentation, updating the thumb path & adding the thumb to image_manager
"""
@ -274,7 +274,7 @@ class TestServiceItem(TestCase):
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
self.assertEqual(1, mocked_image_manager.add_image.call_count, 'image_manager should be used')
def service_item_load_optical_media_from_service_test(self):
def test_service_item_load_optical_media_from_service(self):
"""
Test the Service Item - load an optical media item
"""
@ -295,7 +295,7 @@ class TestServiceItem(TestCase):
self.assertEqual(service_item.end_time, 672.069, 'End time should be 672.069')
self.assertEqual(service_item.media_length, 17.694, 'Media length should be 17.694')
def service_item_load_song_and_audio_from_service_test(self):
def test_service_item_load_song_and_audio_from_service(self):
"""
Test the Service Item - adding a song slide from a saved service
"""

View File

@ -44,7 +44,7 @@ class TestTheme(TestCase):
"""
pass
def new_theme_test(self):
def test_new_theme(self):
"""
Test the theme creation - basic test
"""

View File

@ -37,7 +37,7 @@ class TestUi(TestCase):
Test the functions in the ui module
"""
def add_welcome_page_test(self):
def test_add_welcome_page(self):
"""
Test appending a welcome page to a wizard
"""
@ -51,7 +51,7 @@ class TestUi(TestCase):
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
self.assertIsInstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap)
def create_button_box_test(self):
def test_create_button_box(self):
"""
Test creating a button box for a dialog
"""
@ -79,7 +79,7 @@ class TestUi(TestCase):
self.assertEqual(1, len(btnbox.buttons()))
self.assertEqual(QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
def create_horizontal_adjusting_combo_box_test(self):
def test_create_horizontal_adjusting_combo_box(self):
"""
Test creating a horizontal adjusting combo box
"""
@ -94,7 +94,7 @@ class TestUi(TestCase):
self.assertEqual('combo1', combo.objectName())
self.assertEqual(QtWidgets.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy())
def create_button_test(self):
def test_create_button(self):
"""
Test creating a button
"""
@ -126,7 +126,7 @@ class TestUi(TestCase):
self.assertEqual('my_btn', btn.objectName())
self.assertTrue(btn.isEnabled())
def create_action_test(self):
def test_create_action(self):
"""
Test creating an action
"""
@ -151,7 +151,7 @@ class TestUi(TestCase):
self.assertEqual('my tooltip', action.toolTip())
self.assertEqual('my statustip', action.statusTip())
def create_action_on_mac_osx_test(self):
def test_create_action_on_mac_osx(self):
"""
Test creating an action on OS X calls the correct method
"""
@ -169,7 +169,7 @@ class TestUi(TestCase):
# THEN: setIconVisibleInMenu should be called
mocked_action.setIconVisibleInMenu.assert_called_with(False)
def create_action_not_on_mac_osx_test(self):
def test_create_action_not_on_mac_osx(self):
"""
Test creating an action on something other than OS X doesn't call the method
"""
@ -188,7 +188,7 @@ class TestUi(TestCase):
self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
'setIconVisibleInMenu should not have been called')
def create_checked_disabled_invisible_action_test(self):
def test_create_checked_disabled_invisible_action(self):
"""
Test that an invisible, disabled, checked action is created correctly
"""
@ -203,7 +203,7 @@ class TestUi(TestCase):
self.assertFalse(action.isEnabled(), 'The action should be disabled')
self.assertFalse(action.isVisible(), 'The action should be invisble')
def create_action_separator_test(self):
def test_create_action_separator(self):
"""
Test creating an action as separator
"""
@ -216,7 +216,7 @@ class TestUi(TestCase):
# THEN: The action should be a separator
self.assertTrue(action.isSeparator(), 'The action should be a separator')
def create_valign_selection_widgets_test(self):
def test_create_valign_selection_widgets(self):
"""
Test creating a combo box for valign selection
"""
@ -233,7 +233,7 @@ class TestUi(TestCase):
for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]:
self.assertTrue(combo.findText(text) >= 0)
def find_and_set_in_combo_box_test(self):
def test_find_and_set_in_combo_box(self):
"""
Test finding a string in a combo box and setting it as the selected item if present
"""
@ -260,7 +260,7 @@ class TestUi(TestCase):
# THEN: The index should have changed
self.assertEqual(2, combo.currentIndex())
def create_widget_action_test(self):
def test_create_widget_action(self):
"""
Test creating an action for a widget
"""
@ -274,7 +274,7 @@ class TestUi(TestCase):
self.assertIsInstance(action, QtWidgets.QAction)
self.assertEqual(action.objectName(), 'some action')
def set_case_insensitive_completer_test(self):
def test_set_case_insensitive_completer(self):
"""
Test setting a case insensitive completer on a widget
"""

View File

@ -33,7 +33,7 @@ class TestUtils(TestCase):
"""
A test suite to test out various methods around the AppLocation class.
"""
def get_user_agent_linux_test(self):
def test_get_user_agent_linux(self):
"""
Test that getting a user agent on Linux returns a user agent suitable for Linux
"""
@ -49,7 +49,7 @@ class TestUtils(TestCase):
result = 'Linux' in user_agent or 'CrOS' in user_agent
self.assertTrue(result, 'The user agent should be a valid Linux user agent')
def get_user_agent_windows_test(self):
def test_get_user_agent_windows(self):
"""
Test that getting a user agent on Windows returns a user agent suitable for Windows
"""
@ -64,7 +64,7 @@ class TestUtils(TestCase):
# THEN: The user agent is a Linux (or ChromeOS) user agent
self.assertIn('Windows', user_agent, 'The user agent should be a valid Windows user agent')
def get_user_agent_macos_test(self):
def test_get_user_agent_macos(self):
"""
Test that getting a user agent on OS X returns a user agent suitable for OS X
"""
@ -79,7 +79,7 @@ class TestUtils(TestCase):
# THEN: The user agent is a Linux (or ChromeOS) user agent
self.assertIn('Mac OS X', user_agent, 'The user agent should be a valid OS X user agent')
def get_user_agent_default_test(self):
def test_get_user_agent_default(self):
"""
Test that getting a user agent on a non-Linux/Windows/OS X platform returns the default user agent
"""
@ -94,7 +94,7 @@ class TestUtils(TestCase):
# THEN: The user agent is a Linux (or ChromeOS) user agent
self.assertIn('NetBSD', user_agent, 'The user agent should be the default user agent')
def get_web_page_no_url_test(self):
def test_get_web_page_no_url(self):
"""
Test that sending a URL of None to the get_web_page method returns None
"""
@ -107,7 +107,7 @@ class TestUtils(TestCase):
# THEN: None should be returned
self.assertIsNone(result, 'The return value of get_web_page should be None')
def get_web_page_test(self):
def test_get_web_page(self):
"""
Test that the get_web_page method works correctly
"""
@ -137,7 +137,7 @@ class TestUtils(TestCase):
self.assertEqual(0, MockRegistry.call_count, 'The Registry() object should have never been called')
self.assertEqual(mocked_page_object, returned_page, 'The returned page should be the mock object')
def get_web_page_with_header_test(self):
def test_get_web_page_with_header(self):
"""
Test that adding a header to the call to get_web_page() adds the header to the request
"""
@ -166,7 +166,7 @@ class TestUtils(TestCase):
mocked_page_object.geturl.assert_called_with()
self.assertEqual(mocked_page_object, returned_page, 'The returned page should be the mock object')
def get_web_page_with_user_agent_in_headers_test(self):
def test_get_web_page_with_user_agent_in_headers(self):
"""
Test that adding a user agent in the header when calling get_web_page() adds that user agent to the request
"""
@ -194,7 +194,7 @@ class TestUtils(TestCase):
mocked_page_object.geturl.assert_called_with()
self.assertEqual(mocked_page_object, returned_page, 'The returned page should be the mock object')
def get_web_page_update_openlp_test(self):
def test_get_web_page_update_openlp(self):
"""
Test that passing "update_openlp" as true to get_web_page calls Registry().get('app').process_events()
"""

View File

@ -38,7 +38,7 @@ class TestFirstTimeWizard(TestMixin, TestCase):
"""
Test First Time Wizard import functions
"""
def webpage_connection_retry_test(self):
def test_webpage_connection_retry(self):
"""
Test get_web_page will attempt CONNECTION_RETRIES+1 connections - bug 1409031
"""

View File

@ -78,7 +78,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
if os.path.isfile(self.tempfile):
os.remove(self.tempfile)
def initialise_test(self):
def test_initialise(self):
"""
Test if we can intialise the FirstTimeForm
"""
@ -97,7 +97,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
self.assertListEqual([], frw.theme_screenshot_workers, 'The list of workers should be empty')
self.assertFalse(frw.has_run_wizard, 'has_run_wizard should be False')
def set_defaults_test(self):
def test_set_defaults(self):
"""
Test that the default values are set when set_defaults() is run
"""
@ -134,7 +134,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
mocked_gettempdir.assert_called_with()
mocked_check_directory_exists.assert_called_with(expected_temp_path)
def update_screen_list_combo_test(self):
def test_update_screen_list_combo(self):
"""
Test that the update_screen_list_combo() method works correctly
"""
@ -157,7 +157,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
mocked_display_combo_box.count.assert_called_with()
mocked_display_combo_box.setCurrentIndex.assert_called_with(1)
def on_cancel_button_clicked_test(self):
def test_on_cancel_button_clicked(self):
"""
Test that the cancel button click slot shuts down the threads correctly
"""
@ -184,7 +184,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
self.assertEqual(1, mocked_time.sleep.call_count, 'sleep() should have only been called once')
mocked_set_normal_cursor.assert_called_with()
def broken_config_test(self):
def test_broken_config(self):
"""
Test if we can handle an config file with missing data
"""
@ -200,7 +200,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
# THEN: The First Time Form should not have web access
self.assertFalse(first_time_form.web_access, 'There should not be web access with a broken config file')
def invalid_config_test(self):
def test_invalid_config(self):
"""
Test if we can handle an config file in invalid format
"""
@ -218,7 +218,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
@patch('openlp.core.ui.firsttimeform.get_web_page')
@patch('openlp.core.ui.firsttimeform.QtWidgets.QMessageBox')
def network_error_test(self, mocked_message_box, mocked_get_web_page):
def test_network_error(self, mocked_message_box, mocked_get_web_page):
"""
Test we catch a network error in First Time Wizard - bug 1409627
"""
@ -238,7 +238,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
'first_time_form should have caught Network Error')
@patch('openlp.core.ui.firsttimeform.urllib.request.urlopen')
def socket_timeout_test(self, mocked_urlopen):
def test_socket_timeout(self, mocked_urlopen):
"""
Test socket timeout gets caught
"""

View File

@ -32,7 +32,7 @@ class TestFormattingTagController(TestCase):
def setUp(self):
self.services = FormattingTagController()
def strip_test(self):
def test_strip(self):
"""
Test that the _strip strips the correct chars
"""
@ -45,7 +45,7 @@ class TestFormattingTagController(TestCase):
# THEN: The tag should be returned with the wrappers removed.
self.assertEqual(result, 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'')
def end_tag_changed_processes_correctly_test(self):
def test_end_tag_changed_processes_correctly(self):
"""
Test that the end html tags are generated correctly
"""
@ -70,7 +70,7 @@ class TestFormattingTagController(TestCase):
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
error)
def start_tag_changed_processes_correctly_test(self):
def test_start_tag_changed_processes_correctly(self):
"""
Test that the end html tags are generated correctly
"""
@ -93,7 +93,7 @@ class TestFormattingTagController(TestCase):
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
error)
def start_html_to_end_html_test(self):
def test_start_html_to_end_html(self):
"""
Test that the end html tags are generated correctly
"""

View File

@ -50,7 +50,7 @@ class TestFormattingTagForm(TestCase):
"""
self.setup_patcher.stop()
def on_row_selected_test(self):
def test_on_row_selected(self):
"""
Test that the appropriate actions are preformed when on_row_selected is called
"""
@ -64,7 +64,7 @@ class TestFormattingTagForm(TestCase):
# THEN: setEnabled and should have been called on delete_button
form.delete_button.setEnabled.assert_called_with(True)
def on_new_clicked_test(self):
def test_on_new_clicked(self):
"""
Test that clicking the Add a new tag button does the right thing
"""

View File

@ -70,7 +70,7 @@ class TestMainDisplay(TestCase, TestMixin):
self.mocked_audio_player.stop()
del self.screens
def initial_main_display_test(self):
def test_initial_main_display(self):
"""
Test the initial Main Display state
"""
@ -84,7 +84,7 @@ class TestMainDisplay(TestCase, TestMixin):
# THEN: The controller should be a live controller.
self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
def set_transparency_enabled_test(self):
def test_set_transparency_enabled(self):
"""
Test setting the display to be transparent
"""
@ -103,7 +103,7 @@ class TestMainDisplay(TestCase, TestMixin):
self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
'The MainDisplay should have a translucent background')
def set_transparency_disabled_test(self):
def test_set_transparency_disabled(self):
"""
Test setting the display to be opaque
"""
@ -120,7 +120,7 @@ class TestMainDisplay(TestCase, TestMixin):
self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
'The MainDisplay should not have a translucent background')
def css_changed_test(self):
def test_css_changed(self):
"""
Test that when the CSS changes, the plugins are looped over and given an opportunity to update the CSS
"""
@ -143,7 +143,7 @@ class TestMainDisplay(TestCase, TestMixin):
mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)
@skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
def macosx_display_window_flags_state_test(self):
def test_macosx_display_window_flags_state(self):
"""
Test that on Mac OS X we set the proper window flags
"""
@ -160,7 +160,7 @@ class TestMainDisplay(TestCase, TestMixin):
'The window flags should be Qt.Window, and Qt.FramelessWindowHint.')
@skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
def macosx_display_test(self):
def test_macosx_display(self):
"""
Test display on Mac OS X
"""
@ -186,7 +186,7 @@ class TestMainDisplay(TestCase, TestMixin):
'Window collection behavior should be NSWindowCollectionBehaviorManaged')
@patch(u'openlp.core.ui.maindisplay.Settings')
def show_display_startup_logo_test(self, MockedSettings):
def test_show_display_startup_logo(self, MockedSettings):
# GIVEN: Mocked show_display, setting for logo visibility
display = MagicMock()
main_display = MainDisplay(display)
@ -206,7 +206,7 @@ class TestMainDisplay(TestCase, TestMixin):
main_display.setVisible.assert_called_once_with(True)
@patch(u'openlp.core.ui.maindisplay.Settings')
def show_display_hide_startup_logo_test(self, MockedSettings):
def test_show_display_hide_startup_logo(self, MockedSettings):
# GIVEN: Mocked show_display, setting for logo visibility
display = MagicMock()
main_display = MainDisplay(display)
@ -227,7 +227,7 @@ class TestMainDisplay(TestCase, TestMixin):
@patch(u'openlp.core.ui.maindisplay.Settings')
@patch(u'openlp.core.ui.maindisplay.build_html')
def build_html_no_video_test(self, MockedSettings, Mocked_build_html):
def test_build_html_no_video(self, MockedSettings, Mocked_build_html):
# GIVEN: Mocked display
display = MagicMock()
mocked_media_controller = MagicMock()
@ -255,7 +255,7 @@ class TestMainDisplay(TestCase, TestMixin):
@patch(u'openlp.core.ui.maindisplay.Settings')
@patch(u'openlp.core.ui.maindisplay.build_html')
def build_html_video_test(self, MockedSettings, Mocked_build_html):
def test_build_html_video(self, MockedSettings, Mocked_build_html):
# GIVEN: Mocked display
display = MagicMock()
mocked_media_controller = MagicMock()

View File

@ -72,7 +72,7 @@ class TestMainWindow(TestCase, TestMixin):
def tearDown(self):
del self.main_window
def cmd_line_file_test(self):
def test_cmd_line_file(self):
"""
Test that passing a service file from the command line loads the service.
"""
@ -87,7 +87,7 @@ class TestMainWindow(TestCase, TestMixin):
# THEN the service from the arguments is loaded
mocked_load_path.assert_called_with(service), 'load_path should have been called with the service\'s path'
def cmd_line_arg_test(self):
def test_cmd_line_arg(self):
"""
Test that passing a non service file does nothing.
"""
@ -102,7 +102,7 @@ class TestMainWindow(TestCase, TestMixin):
# THEN the file should not be opened
assert not mocked_load_path.called, 'load_path should not have been called'
def main_window_title_test(self):
def test_main_window_title(self):
"""
Test that running a new instance of OpenLP set the window title correctly
"""
@ -114,7 +114,7 @@ class TestMainWindow(TestCase, TestMixin):
self.assertEqual(self.main_window.windowTitle(), UiStrings().OLPV2x,
'The main window\'s title should be the same as the OLPV2x string in UiStrings class')
def set_service_modifed_test(self):
def test_set_service_modifed(self):
"""
Test that when setting the service's title the main window's title is set correctly
"""
@ -127,7 +127,7 @@ class TestMainWindow(TestCase, TestMixin):
self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OLPV2x, 'test.osz'),
'The main window\'s title should be set to "<the contents of UiStrings().OLPV2x> - test.osz*"')
def set_service_unmodified_test(self):
def test_set_service_unmodified(self):
"""
Test that when setting the service's title the main window's title is set correctly
"""
@ -140,7 +140,7 @@ class TestMainWindow(TestCase, TestMixin):
self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OLPV2x, 'test.osz'),
'The main window\'s title should be set to "<the contents of UiStrings().OLPV2x> - test.osz"')
def mainwindow_configuration_test(self):
def test_mainwindow_configuration(self):
"""
Check that the Main Window initialises the Registry Correctly
"""
@ -158,7 +158,7 @@ class TestMainWindow(TestCase, TestMixin):
self.assertTrue('plugin_manager' in self.registry.service_list,
'The plugin_manager should have been registered.')
def on_search_shortcut_triggered_shows_media_manager_test(self):
def test_on_search_shortcut_triggered_shows_media_manager(self):
"""
Test that the media manager is made visible when the search shortcut is triggered
"""
@ -174,7 +174,7 @@ class TestMainWindow(TestCase, TestMixin):
# THEN: The media manager dock is made visible
mocked_media_manager_dock.setVisible.assert_called_with(True)
def on_search_shortcut_triggered_focuses_widget_test(self):
def test_on_search_shortcut_triggered_focuses_widget(self):
"""
Test that the focus is set on the widget when the search shortcut is triggered
"""
@ -198,7 +198,7 @@ class TestMainWindow(TestCase, TestMixin):
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.warning')
@patch('openlp.core.ui.mainwindow.Settings')
def on_first_time_wizard_clicked_show_projectors_after_test(self, mocked_Settings, mocked_warning,
def test_on_first_time_wizard_clicked_show_projectors_after(self, mocked_Settings, mocked_warning,
mocked_FirstTimeForm, mocked_application,
mocked_first_time,
mocked_plugin_manager):
@ -225,7 +225,7 @@ class TestMainWindow(TestCase, TestMixin):
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.warning')
@patch('openlp.core.ui.mainwindow.Settings')
def on_first_time_wizard_clicked_hide_projectors_after_test(self, mocked_Settings, mocked_warning,
def test_on_first_time_wizard_clicked_hide_projectors_after(self, mocked_Settings, mocked_warning,
mocked_FirstTimeForm, mocked_application,
mocked_first_time,
mocked_plugin_manager):

View File

@ -40,7 +40,7 @@ class TestServiceManager(TestCase):
"""
Registry.create()
def initial_service_manager_test(self):
def test_initial_service_manager(self):
"""
Test the initial of service manager.
"""
@ -50,7 +50,7 @@ class TestServiceManager(TestCase):
# THEN: The the controller should be registered in the registry.
self.assertNotEqual(Registry().get('service_manager'), None, 'The base service manager should be registered')
def create_basic_service_test(self):
def test_create_basic_service(self):
"""
Test the create basic service array
"""
@ -65,7 +65,7 @@ class TestServiceManager(TestCase):
self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved')
self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved')
def supported_suffixes_test(self):
def test_supported_suffixes(self):
"""
Test the create basic service array
"""
@ -79,7 +79,7 @@ class TestServiceManager(TestCase):
self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list')
self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list')
def build_context_menu_test(self):
def test_build_context_menu(self):
"""
Test the creation of a context menu from a null service item.
"""
@ -123,7 +123,7 @@ class TestServiceManager(TestCase):
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
'Should have been called once')
def build_song_context_menu_test(self):
def test_build_song_context_menu(self):
"""
Test the creation of a context menu from service item of type text from Songs.
"""
@ -189,7 +189,7 @@ class TestServiceManager(TestCase):
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
def build_bible_context_menu_test(self):
def test_build_bible_context_menu(self):
"""
Test the creation of a context menu from service item of type text from Bibles.
"""
@ -254,7 +254,7 @@ class TestServiceManager(TestCase):
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
def build_custom_context_menu_test(self):
def test_build_custom_context_menu(self):
"""
Test the creation of a context menu from service item of type text from Custom.
"""
@ -319,7 +319,7 @@ class TestServiceManager(TestCase):
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
def build_image_context_menu_test(self):
def test_build_image_context_menu(self):
"""
Test the creation of a context menu from service item of type Image from Image.
"""
@ -382,7 +382,7 @@ class TestServiceManager(TestCase):
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
def build_media_context_menu_test(self):
def test_build_media_context_menu(self):
"""
Test the creation of a context menu from service item of type Command from Media.
"""
@ -439,7 +439,7 @@ class TestServiceManager(TestCase):
# THEN the following additional calls should have occurred.
self.assertEquals(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
def build_presentation_pdf_context_menu_test(self):
def test_build_presentation_pdf_context_menu(self):
"""
Test the creation of a context menu from service item of type Command with PDF from Presentation.
"""
@ -492,7 +492,7 @@ class TestServiceManager(TestCase):
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
'Should have be called once')
def build_presentation_non_pdf_context_menu_test(self):
def test_build_presentation_non_pdf_context_menu(self):
"""
Test the creation of a context menu from service item of type Command with Impress from Presentation.
"""

View File

@ -39,7 +39,7 @@ class TestSettingsForm(TestCase):
"""
Registry.create()
def insert_tab_visible_test(self):
def test_insert_tab_visible(self):
"""
Test that the insert_tab() method works correctly when a visible tab is inserted
"""
@ -59,7 +59,7 @@ class TestSettingsForm(TestCase):
mocked_add_widget.assert_called_with(general_tab)
self.assertEqual(1, mocked_add_item.call_count, 'addItem should have been called')
def insert_tab_not_visible_test(self):
def test_insert_tab_not_visible(self):
"""
Test that the insert_tab() method works correctly when a tab that should not be visible is inserted
"""
@ -77,7 +77,7 @@ class TestSettingsForm(TestCase):
mocked_add_widget.assert_called_with(general_tab)
self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called')
def accept_with_inactive_plugins_test(self):
def test_accept_with_inactive_plugins(self):
"""
Test that the accept() method works correctly when some of the plugins are inactive
"""
@ -105,7 +105,7 @@ class TestSettingsForm(TestCase):
mocked_general_save.assert_called_with()
self.assertEqual(0, mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called')
def list_item_changed_invalid_item_test(self):
def test_list_item_changed_invalid_item(self):
"""
Test that the list_item_changed() slot handles a non-existent item
"""
@ -124,7 +124,7 @@ class TestSettingsForm(TestCase):
# THEN: The rest of the method should not have been called
self.assertEqual(0, mocked_count.call_count, 'The count method of the stacked layout should not be called')
def reject_with_inactive_items_test(self):
def test_reject_with_inactive_items(self):
"""
Test that the reject() method works correctly when some of the plugins are inactive
"""

View File

@ -35,7 +35,7 @@ from tests.functional import MagicMock, patch
class TestSlideController(TestCase):
def initial_slide_controller_test(self):
def test_initial_slide_controller(self):
"""
Test the initial slide controller state .
"""
@ -46,7 +46,7 @@ class TestSlideController(TestCase):
# THEN: The controller should not be a live controller.
self.assertEqual(slide_controller.is_live, False, 'The base slide controller should not be a live controller')
def text_service_item_blank_test(self):
def test_text_service_item_blank(self):
"""
Test that loading a text-based service item into the slide controller sets the correct blank menu
"""
@ -65,7 +65,7 @@ class TestSlideController(TestCase):
# THEN: the call to set the visible items on the toolbar should be correct
toolbar.set_widget_visible.assert_called_with(WIDE_MENU, True)
def non_text_service_item_blank_test(self):
def test_non_text_service_item_blank(self):
"""
Test that loading a non-text service item into the slide controller sets the correct blank menu
"""
@ -85,7 +85,7 @@ class TestSlideController(TestCase):
toolbar.set_widget_visible.assert_called_with(NON_TEXT_MENU, True)
@patch('openlp.core.ui.slidecontroller.Settings')
def receive_spin_delay_test(self, MockedSettings):
def test_receive_spin_delay(self, MockedSettings):
"""
Test that the spin box is updated accordingly after a call to receive_spin_delay()
"""
@ -103,7 +103,7 @@ class TestSlideController(TestCase):
mocked_value.assert_called_with('core/loop delay')
mocked_delay_spin_box.setValue.assert_called_with(1)
def toggle_display_blank_test(self):
def test_toggle_display_blank(self):
"""
Check that the toggle_display('blank') method calls the on_blank_display() method
"""
@ -124,7 +124,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
def toggle_display_hide_test(self):
def test_toggle_display_hide(self):
"""
Check that the toggle_display('hide') method calls the on_blank_display() method
"""
@ -145,7 +145,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
def toggle_display_theme_test(self):
def test_toggle_display_theme(self):
"""
Check that the toggle_display('theme') method calls the on_theme_display() method
"""
@ -166,7 +166,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called')
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
def toggle_display_desktop_test(self):
def test_toggle_display_desktop(self):
"""
Check that the toggle_display('desktop') method calls the on_hide_display() method
"""
@ -187,7 +187,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called')
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
def toggle_display_show_test(self):
def test_toggle_display_show(self):
"""
Check that the toggle_display('show') method calls all the on_X_display() methods
"""
@ -208,7 +208,7 @@ class TestSlideController(TestCase):
mocked_on_theme_display.assert_called_once_with(False)
mocked_on_hide_display.assert_called_once_with(False)
def live_escape_test(self):
def test_live_escape(self):
"""
Test that when the live_escape() method is called, the display is set to invisible and any media is stopped
"""
@ -231,7 +231,7 @@ class TestSlideController(TestCase):
mocked_display.setVisible.assert_called_once_with(False)
mocked_media_controller.media_stop.assert_called_once_with(slide_controller)
def on_go_live_live_controller_test(self):
def test_on_go_live_live_controller(self):
"""
Test that when the on_go_live() method is called the message is sent to the live controller and focus is
set correctly.
@ -259,7 +259,7 @@ class TestSlideController(TestCase):
mocked_live_controller.add_service_manager_item.assert_called_once_with(mocked_service_item, 1)
mocked_live_controller.preview_widget.setFocus.assert_called_once_with()
def on_go_live_service_manager_test(self):
def test_on_go_live_service_manager(self):
"""
Test that when the on_go_live() method is called the message is sent to the live controller and focus is
set correctly.
@ -290,7 +290,7 @@ class TestSlideController(TestCase):
mocked_service_manager.preview_live.assert_called_once_with(42, 1)
mocked_live_controller.preview_widget.setFocus.assert_called_once_with()
def service_previous_test(self):
def test_service_previous(self):
"""
Check that calling the service_previous() method adds the previous key to the queue and processes the queue
"""
@ -308,7 +308,7 @@ class TestSlideController(TestCase):
mocked_keypress_queue.append.assert_called_once_with(ServiceItemAction.Previous)
mocked_process_queue.assert_called_once_with()
def service_next_test(self):
def test_service_next(self):
"""
Check that calling the service_next() method adds the next key to the queue and processes the queue
"""
@ -327,7 +327,7 @@ class TestSlideController(TestCase):
mocked_process_queue.assert_called_once_with()
@patch('openlp.core.ui.slidecontroller.Settings')
def update_slide_limits_test(self, MockedSettings):
def test_update_slide_limits(self, MockedSettings):
"""
Test that calling the update_slide_limits() method updates the slide limits
"""
@ -346,7 +346,7 @@ class TestSlideController(TestCase):
mocked_value.assert_called_once_with('advanced/slide limits')
self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10')
def enable_tool_bar_live_test(self):
def test_enable_tool_bar_live(self):
"""
Check that when enable_tool_bar on a live slide controller is called, enable_live_tool_bar is called
"""
@ -366,7 +366,7 @@ class TestSlideController(TestCase):
mocked_enable_live_tool_bar.assert_called_once_with(mocked_service_item)
self.assertEqual(0, mocked_enable_preview_tool_bar.call_count, 'The preview method should not have been called')
def enable_tool_bar_preview_test(self):
def test_enable_tool_bar_preview(self):
"""
Check that when enable_tool_bar on a preview slide controller is called, enable_preview_tool_bar is called
"""
@ -386,7 +386,7 @@ class TestSlideController(TestCase):
mocked_enable_preview_tool_bar.assert_called_once_with(mocked_service_item)
self.assertEqual(0, mocked_enable_live_tool_bar.call_count, 'The live method should not have been called')
def refresh_service_item_text_test(self):
def test_refresh_service_item_text(self):
"""
Test that the refresh_service_item() method refreshes a text service item
"""
@ -409,7 +409,7 @@ class TestSlideController(TestCase):
mocked_service_item.render.assert_called_once_with()
mocked_process_item.assert_called_once_with(mocked_service_item, 5)
def refresh_service_item_image_test(self):
def test_refresh_service_item_image(self):
"""
Test that the refresh_service_item() method refreshes a image service item
"""
@ -432,7 +432,7 @@ class TestSlideController(TestCase):
mocked_service_item.render.assert_called_once_with()
mocked_process_item.assert_called_once_with(mocked_service_item, 5)
def refresh_service_item_not_image_or_text_test(self):
def test_refresh_service_item_not_image_or_text(self):
"""
Test that the refresh_service_item() method does not refresh a service item if it's neither text or an image
"""
@ -456,7 +456,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_process_item.call_count,
'The mocked_process_item() method should not have been called')
def add_service_item_with_song_edit_test(self):
def test_add_service_item_with_song_edit(self):
"""
Test the add_service_item() method when song_edit is True
"""
@ -476,7 +476,7 @@ class TestSlideController(TestCase):
self.assertFalse(slide_controller.song_edit, 'song_edit should be False')
mocked_process_item.assert_called_once_with(mocked_item, 2)
def add_service_item_without_song_edit_test(self):
def test_add_service_item_without_song_edit(self):
"""
Test the add_service_item() method when song_edit is False
"""
@ -496,7 +496,7 @@ class TestSlideController(TestCase):
self.assertFalse(slide_controller.song_edit, 'song_edit should be False')
mocked_process_item.assert_called_once_with(mocked_item, 0)
def replace_service_manager_item_different_items_test(self):
def test_replace_service_manager_item_different_items(self):
"""
Test that when the service items are not the same, nothing happens
"""
@ -517,7 +517,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_preview_widget.current_slide_number.call_count,
'The preview_widgetcurrent_slide_number.() method should not have been called')
def replace_service_manager_item_same_item_test(self):
def test_replace_service_manager_item_same_item(self):
"""
Test that when the service item is the same, the service item is reprocessed
"""
@ -538,7 +538,7 @@ class TestSlideController(TestCase):
mocked_preview_widget.current_slide_number.assert_called_with()
mocked_process_item.assert_called_once_with(mocked_item, 7)
def on_slide_blank_test(self):
def test_on_slide_blank(self):
"""
Test on_slide_blank
"""
@ -552,7 +552,7 @@ class TestSlideController(TestCase):
# THEN: on_blank_display should have been called with True
slide_controller.on_blank_display.assert_called_once_with(True)
def on_slide_unblank_test(self):
def test_on_slide_unblank(self):
"""
Test on_slide_unblank
"""
@ -566,7 +566,7 @@ class TestSlideController(TestCase):
# THEN: on_blank_display should have been called with False
slide_controller.on_blank_display.assert_called_once_with(False)
def on_slide_selected_index_no_service_item_test(self):
def test_on_slide_selected_index_no_service_item(self):
"""
Test that when there is no service item, the on_slide_selected_index() method returns immediately
"""
@ -582,7 +582,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_item.is_command.call_count, 'The service item should have not been called')
@patch.object(Registry, 'execute')
def on_slide_selected_index_service_item_command_test(self, mocked_execute):
def test_on_slide_selected_index_service_item_command(self, mocked_execute):
"""
Test that when there is a command service item, the command is executed
"""
@ -612,7 +612,7 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called')
@patch.object(Registry, 'execute')
def on_slide_selected_index_service_item_not_command_test(self, mocked_execute):
def test_on_slide_selected_index_service_item_not_command(self, mocked_execute):
"""
Test that when there is a service item but it's not a command, the preview widget is updated
"""
@ -641,7 +641,7 @@ class TestSlideController(TestCase):
mocked_slide_selected.assert_called_once_with()
@patch.object(Registry, 'execute')
def process_item_test(self, mocked_execute):
def test_process_item(self, mocked_execute):
"""
Test that presentation service-items is closed when followed by a media service-item
"""
@ -685,7 +685,7 @@ class TestSlideController(TestCase):
self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
'The presentation should have been stopped.')
def live_stolen_focus_shortcuts_test(self):
def test_live_stolen_focus_shortcuts(self):
"""
Test that all the needed shortcuts are available in scenarios where Live has stolen focus.
These are found under def __add_actions_to_widget(self, widget): in slidecontroller.py
@ -885,7 +885,7 @@ class TestSlideController(TestCase):
class TestInfoLabel(TestCase):
def paint_event_text_fits_test(self):
def test_paint_event_text_fits(self):
"""
Test the paintEvent method when text fits the label
"""
@ -913,7 +913,7 @@ class TestInfoLabel(TestCase):
# THEN: The text should be drawn centered with the complete test_string
mocked_qpainter().drawText.assert_called_once_with(mocked_rect(), QtCore.Qt.AlignCenter, test_string)
def paint_event_text_doesnt_fit_test(self):
def test_paint_event_text_doesnt_fit(self):
"""
Test the paintEvent method when text fits the label
"""
@ -944,7 +944,7 @@ class TestInfoLabel(TestCase):
mocked_qpainter().drawText.assert_called_once_with(mocked_rect(), QtCore.Qt.AlignLeft, elided_test_string)
@patch('builtins.super')
def set_text_test(self, mocked_super):
def test_set_text(self, mocked_super):
"""
Test the reimplemented setText method
"""
@ -963,7 +963,7 @@ class TestInfoLabel(TestCase):
class TestLiveController(TestCase):
def initial_live_controller_test(self):
def test_initial_live_controller(self):
"""
Test the initial live slide controller state .
"""
@ -978,7 +978,7 @@ class TestLiveController(TestCase):
class TestPreviewLiveController(TestCase):
def initial_preview_controller_test(self):
def test_initial_preview_controller(self):
"""
Test the initial preview slide controller state.
"""

View File

@ -34,7 +34,7 @@ class TestThemeManager(TestCase):
"""
Test the functions in the ThemeManager Class
"""
def select_image_file_dialog_cancelled_test(self):
def test_select_image_file_dialog_cancelled(self):
"""
Test the select image file dialog when the user presses cancel
"""
@ -62,7 +62,7 @@ class TestThemeManager(TestCase):
'All Files (*.*)')
mocked_set_background_page_values.assert_called_once_with()
def select_image_file_dialog_new_file_test(self):
def test_select_image_file_dialog_new_file(self):
"""
Test the select image file dialog when the user presses ok
"""

View File

@ -53,7 +53,7 @@ class TestThemeManager(TestCase):
"""
shutil.rmtree(self.temp_folder)
def export_theme_test(self):
def test_export_theme(self):
"""
Test exporting a theme .
"""
@ -73,7 +73,7 @@ class TestThemeManager(TestCase):
'Default', 'Default.xml'),
os.path.join('Default', 'Default.xml'))
def initial_theme_manager_test(self):
def test_initial_theme_manager(self):
"""
Test the instantiation of theme manager.
"""
@ -84,7 +84,7 @@ class TestThemeManager(TestCase):
# THEN: The the controller should be registered in the registry.
self.assertIsNotNone(Registry().get('theme_manager'), 'The base theme manager should be registered')
def write_theme_same_image_test(self):
def test_write_theme_same_image(self):
"""
Test that we don't try to overwrite a theme background image with itself
"""
@ -112,7 +112,7 @@ class TestThemeManager(TestCase):
# THEN: The mocked_copyfile should not have been called
self.assertFalse(mocked_copyfile.called, 'shutil.copyfile should not be called')
def write_theme_diff_images_test(self):
def test_write_theme_diff_images(self):
"""
Test that we do overwrite a theme background image when a new is submitted
"""
@ -139,7 +139,7 @@ class TestThemeManager(TestCase):
# THEN: The mocked_copyfile should not have been called
self.assertTrue(mocked_copyfile.called, 'shutil.copyfile should be called')
def write_theme_special_char_name_test(self):
def test_write_theme_special_char_name(self):
"""
Test that we can save themes with special characters in the name
"""
@ -160,7 +160,7 @@ class TestThemeManager(TestCase):
self.assertTrue(os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.xml')),
'Theme with special characters should have been created!')
def over_write_message_box_yes_test(self):
def test_over_write_message_box_yes(self):
"""
Test that theme_manager.over_write_message_box returns True when the user clicks yes.
"""
@ -180,7 +180,7 @@ class TestThemeManager(TestCase):
theme_manager, 'Theme Already Exists', 'Theme Theme Name already exists. Do you want to replace it?',
ANY, ANY)
def over_write_message_box_no_test(self):
def test_over_write_message_box_no(self):
"""
Test that theme_manager.over_write_message_box returns False when the user clicks no.
"""
@ -200,7 +200,7 @@ class TestThemeManager(TestCase):
theme_manager, 'Theme Already Exists', 'Theme Theme Name already exists. Do you want to replace it?',
ANY, ANY)
def unzip_theme_test(self):
def test_unzip_theme(self):
"""
Test that unzipping of themes works
"""
@ -222,7 +222,7 @@ class TestThemeManager(TestCase):
self.assertEqual(mocked_critical_error_message_box.call_count, 0, 'No errors should have happened')
shutil.rmtree(folder)
def unzip_theme_invalid_version_test(self):
def test_unzip_theme_invalid_version(self):
"""
Test that themes with invalid (< 2.0) or with no version attributes are rejected
"""

View File

@ -49,7 +49,7 @@ class TestColorDialog(TestCase):
self.mocked_qt_widgets = self.qt_gui_patcher.start()
self.mocked_translate = self.translate_patcher.start()
def constructor_test(self):
def test_constructor(self):
"""
Test that constructing a ColorButton object works correctly
"""
@ -67,7 +67,7 @@ class TestColorDialog(TestCase):
mocked_set_tool_tip.assert_called_once_with('Tool Tip Text')
self.mocked_clicked.connect.assert_called_once_with(widget.on_clicked)
def change_color_test(self):
def test_change_color(self):
"""
Test that change_color sets the new color and the stylesheet
"""
@ -87,7 +87,7 @@ class TestColorDialog(TestCase):
self.mocked_change_color = self.change_color_patcher.start()
def color_test(self):
def test_color(self):
"""
Test that the color property method returns the set color
"""
@ -102,7 +102,7 @@ class TestColorDialog(TestCase):
# THEN: The value set in _color should be returned
self.assertEqual(value, '#000000', 'The value returned should be equal to the one we set')
def color_test(self):
def test_color(self):
"""
Test that the color property method returns the set color
"""
@ -117,7 +117,7 @@ class TestColorDialog(TestCase):
# THEN: The value set in _color should be returned
self.assertEqual(value, '#000000', 'The value returned should be equal to the one we set')
def color_setter_test(self):
def test_color_setter(self):
"""
Test that the color property setter method sets the color
"""
@ -132,7 +132,7 @@ class TestColorDialog(TestCase):
# THEN: Then change_color should have been called with the value we set
self.mocked_change_color.assert_called_once_with('#000000')
def on_clicked_invalid_color_test(self):
def test_on_clicked_invalid_color(self):
"""
Test the on_click method when an invalid color has been supplied
"""
@ -154,7 +154,7 @@ class TestColorDialog(TestCase):
self.mocked_color_changed.emit.call_count, 0,
'colorChange signal should not have been emitted with an invalid color')
def on_clicked_same_color_test(self):
def test_on_clicked_same_color(self):
"""
Test the on_click method when a new color has not been chosen
"""
@ -178,7 +178,7 @@ class TestColorDialog(TestCase):
self.mocked_color_changed.emit.call_count, 0,
'colorChange signal should not have been emitted when the color has not changed')
def on_clicked_new_color_test(self):
def test_on_clicked_new_color(self):
"""
Test the on_click method when a new color has been chosen and is valid
"""

View File

@ -61,7 +61,7 @@ class TestListPreviewWidget(TestCase):
self.mocked_viewport.return_value = self.mocked_viewport_obj
self.addCleanup(self.viewport_patcher.stop)
def new_list_preview_widget_test(self):
def test_new_list_preview_widget(self):
"""
Test that creating an instance of ListPreviewWidget works
"""

View File

@ -38,7 +38,7 @@ class TestMediaController(TestCase, TestMixin):
Registry.create()
Registry().register('service_manager', MagicMock())
def generate_extensions_lists_test(self):
def test_generate_extensions_lists(self):
"""
Test that the extensions are create correctly
"""
@ -59,7 +59,7 @@ class TestMediaController(TestCase, TestMixin):
self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,
'Audio extensions should be the same')
def resize_test(self):
def test_resize(self):
"""
Test that the resize method is called correctly
"""
@ -74,7 +74,7 @@ class TestMediaController(TestCase, TestMixin):
# THEN: The player's resize method should be called correctly
mocked_player.resize.assert_called_with(mocked_display)
def check_file_type_no_players_test(self):
def test_check_file_type_no_players(self):
"""
Test that we don't try to play media when no players available
"""
@ -100,7 +100,7 @@ class TestMediaController(TestCase, TestMixin):
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
def check_file_type_no_processor_test(self, mocked_uistrings, mocked_get_used_players):
def test_check_file_type_no_processor(self, mocked_uistrings, mocked_get_used_players):
"""
Test that we don't try to play media when the processor for the service item is None
"""
@ -123,7 +123,7 @@ class TestMediaController(TestCase, TestMixin):
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
def check_file_type_automatic_processor_test(self, mocked_uistrings, mocked_get_used_players):
def test_check_file_type_automatic_processor(self, mocked_uistrings, mocked_get_used_players):
"""
Test that we can play media when players are available and we have a automatic processor from the service item
"""
@ -153,7 +153,7 @@ class TestMediaController(TestCase, TestMixin):
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
def check_file_type_processor_different_from_available_test(self, mocked_uistrings, mocked_get_used_players):
def test_check_file_type_processor_different_from_available(self, mocked_uistrings, mocked_get_used_players):
"""
Test that we can play media when players available are different from the processor from the service item
"""
@ -181,7 +181,7 @@ class TestMediaController(TestCase, TestMixin):
self.assertTrue(ret, '_check_file_type should return True when the players available are different'
'from the processor from the service item.')
def media_play_msg_test(self):
def test_media_play_msg(self):
"""
Test that the media controller responds to the request to play a loaded video
"""
@ -196,7 +196,7 @@ class TestMediaController(TestCase, TestMixin):
# THEN: The underlying method is called
mocked_media_play.assert_called_with(1, False)
def media_pause_msg_test(self):
def test_media_pause_msg(self):
"""
Test that the media controller responds to the request to pause a loaded video
"""
@ -211,7 +211,7 @@ class TestMediaController(TestCase, TestMixin):
# THEN: The underlying method is called
mocked_media_pause.assert_called_with(1)
def media_stop_msg_test(self):
def test_media_stop_msg(self):
"""
Test that the media controller responds to the request to stop a loaded video
"""
@ -226,7 +226,7 @@ class TestMediaController(TestCase, TestMixin):
# THEN: The underlying method is called
mocked_media_stop.assert_called_with(1)
def media_volume_msg_test(self):
def test_media_volume_msg(self):
"""
Test that the media controller responds to the request to change the volume
"""
@ -241,7 +241,7 @@ class TestMediaController(TestCase, TestMixin):
# THEN: The underlying method is called
mocked_media_volume.assert_called_with(1, 50)
def media_seek_msg_test(self):
def test_media_seek_msg(self):
"""
Test that the media controller responds to the request to seek to a particular position
"""

View File

@ -52,7 +52,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@skip('No way to test this')
@patch('openlp.core.ui.media.vlcplayer.vlc')
def get_vlc_fails_and_removes_module_test(self, mocked_vlc):
def test_get_vlc_fails_and_removes_module(self, mocked_vlc):
"""
Test that when the VLC import fails, it removes the module from sys.modules
"""
@ -67,7 +67,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertNotIn('openlp.core.ui.media.vendor.vlc', sys.modules)
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
def fix_vlc_22_plugin_path_test(self, mocked_is_macosx):
def test_fix_vlc_22_plugin_path(self, mocked_is_macosx):
"""
Test that on OS X we set the VLC plugin path to fix a bug in the VLC module
"""
@ -84,7 +84,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch.dict(os.environ)
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
def not_osx_fix_vlc_22_plugin_path_test(self, mocked_is_macosx):
def test_not_osx_fix_vlc_22_plugin_path(self, mocked_is_macosx):
"""
Test that on Linux or some other non-OS X we do not set the VLC plugin path
"""
@ -98,7 +98,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertNotIn('VLC_PLUGIN_PATH', os.environ,
'The plugin path should NOT be in the environment variables')
def init_test(self):
def test_init(self):
"""
Test that the VLC player class initialises correctly
"""
@ -121,7 +121,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.QtWidgets')
@patch('openlp.core.ui.media.vlcplayer.Settings')
def setup_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
def test_setup(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
"""
Test the setup method
"""
@ -171,7 +171,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.QtWidgets')
@patch('openlp.core.ui.media.vlcplayer.Settings')
def setup_has_audio_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
def test_setup_has_audio(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
"""
Test the setup method when has_audio is True
"""
@ -208,7 +208,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.QtWidgets')
@patch('openlp.core.ui.media.vlcplayer.Settings')
def setup_visible_mouse_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx,
def test_setup_visible_mouse(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx,
mocked_is_win):
"""
Test the setup method when Settings().value("hide mouse") is False
@ -246,7 +246,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.QtWidgets')
@patch('openlp.core.ui.media.vlcplayer.Settings')
def setup_windows_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
def test_setup_windows(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
"""
Test the setup method when running on Windows
"""
@ -283,7 +283,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.QtWidgets')
@patch('openlp.core.ui.media.vlcplayer.Settings')
def setup_osx_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
def test_setup_osx(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
"""
Test the setup method when running on OS X
"""
@ -316,7 +316,7 @@ class TestVLCPlayer(TestCase, TestMixin):
mocked_media_player_new.set_nsobject.assert_called_with(2)
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def check_available_test(self, mocked_get_vlc):
def test_check_available(self, mocked_get_vlc):
"""
Check that when the "vlc" module is available, then VLC is set as available
"""
@ -331,7 +331,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertTrue(is_available)
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def check_not_available_test(self, mocked_get_vlc):
def test_check_not_available(self, mocked_get_vlc):
"""
Check that when the "vlc" module is not available, then VLC is set as unavailable
"""
@ -347,7 +347,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.os.path.normcase')
def load_test(self, mocked_normcase, mocked_get_vlc):
def test_load(self, mocked_normcase, mocked_get_vlc):
"""
Test loading a video into VLC
"""
@ -385,7 +385,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.is_win')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.os.path.normcase')
def load_audio_cd_test(self, mocked_normcase, mocked_get_vlc, mocked_is_win):
def test_load_audio_cd(self, mocked_normcase, mocked_get_vlc, mocked_is_win):
"""
Test loading an audio CD into VLC
"""
@ -430,7 +430,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.is_win')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.os.path.normcase')
def load_audio_cd_on_windows_test(self, mocked_normcase, mocked_get_vlc, mocked_is_win):
def test_load_audio_cd_on_windows(self, mocked_normcase, mocked_get_vlc, mocked_is_win):
"""
Test loading an audio CD into VLC on Windows
"""
@ -475,7 +475,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.is_win')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.os.path.normcase')
def load_audio_cd_no_tracks_test(self, mocked_normcase, mocked_get_vlc, mocked_is_win):
def test_load_audio_cd_no_tracks(self, mocked_normcase, mocked_get_vlc, mocked_is_win):
"""
Test loading an audio CD that has no tracks into VLC
"""
@ -519,7 +519,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime)
def media_state_wait_test(self, mocked_get_vlc):
def test_media_state_wait(self, mocked_get_vlc):
"""
Check that waiting for a state change works
"""
@ -542,7 +542,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime)
def media_state_wait_error_test(self, mocked_get_vlc):
def test_media_state_wait_error(self, mocked_get_vlc):
"""
Check that getting an error when waiting for a state change returns False
"""
@ -565,7 +565,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
@patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime)
def media_state_wait_times_out_test(self, mocked_get_vlc):
def test_media_state_wait_times_out(self, mocked_get_vlc):
"""
Check that waiting for a state returns False when it times out after 60 seconds
"""
@ -588,7 +588,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# THEN: The results should be True
self.assertFalse(result)
def resize_test(self):
def test_resize(self):
"""
Test resizing the player
"""
@ -606,7 +606,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.threading')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def play_test(self, mocked_get_vlc, mocked_threading):
def test_play(self, mocked_get_vlc, mocked_threading):
"""
Test the play() method
"""
@ -642,7 +642,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.threading')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def play_media_wait_state_not_playing_test(self, mocked_get_vlc, mocked_threading):
def test_play_media_wait_state_not_playing(self, mocked_get_vlc, mocked_threading):
"""
Test the play() method when media_wait_state() returns False
"""
@ -670,7 +670,7 @@ class TestVLCPlayer(TestCase, TestMixin):
@patch('openlp.core.ui.media.vlcplayer.threading')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def play_dvd_test(self, mocked_get_vlc, mocked_threading):
def test_play_dvd(self, mocked_get_vlc, mocked_threading):
"""
Test the play() method with a DVD
"""
@ -710,7 +710,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertTrue(result, 'The value returned from play() should be True')
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def pause_test(self, mocked_get_vlc):
def test_pause(self, mocked_get_vlc):
"""
Test that the pause method works correctly
"""
@ -735,7 +735,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertEqual(MediaState.Paused, vlc_player.get_live_state())
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def pause_not_playing_test(self, mocked_get_vlc):
def test_pause_not_playing(self, mocked_get_vlc):
"""
Test the pause method when the player is not playing
"""
@ -755,7 +755,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertEqual(0, mocked_display.vlc_media_player.pause.call_count)
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def pause_fail_test(self, mocked_get_vlc):
def test_pause_fail(self, mocked_get_vlc):
"""
Test the pause method when the player fails to pause the media
"""
@ -780,7 +780,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertNotEqual(MediaState.Paused, vlc_player.state)
@patch('openlp.core.ui.media.vlcplayer.threading')
def stop_test(self, mocked_threading):
def test_stop(self, mocked_threading):
"""
Test stopping the current item
"""
@ -800,7 +800,7 @@ class TestVLCPlayer(TestCase, TestMixin):
mocked_thread.start.assert_called_with()
self.assertEqual(MediaState.Stopped, vlc_player.get_live_state())
def volume_test(self):
def test_volume(self):
"""
Test setting the volume
"""
@ -815,7 +815,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# THEN: The volume should have been set
mocked_display.vlc_media_player.audio_set_volume.assert_called_with(10)
def volume_no_audio_test(self):
def test_volume_no_audio(self):
"""
Test setting the volume when there's no audio
"""
@ -830,7 +830,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# THEN: The volume should NOT have been set
self.assertEqual(0, mocked_display.vlc_media_player.audio_set_volume.call_count)
def seek_unseekable_media_test(self):
def test_seek_unseekable_media(self):
"""
Test seeking something that can't be seeked
"""
@ -847,7 +847,7 @@ class TestVLCPlayer(TestCase, TestMixin):
mocked_display.vlc_media_player.is_seekable.assert_called_with()
self.assertEqual(0, mocked_display.vlc_media_player.set_time.call_count)
def seek_seekable_media_test(self):
def test_seek_seekable_media(self):
"""
Test seeking something that is seekable, but not a DVD
"""
@ -864,7 +864,7 @@ class TestVLCPlayer(TestCase, TestMixin):
mocked_display.vlc_media_player.is_seekable.assert_called_with()
mocked_display.vlc_media_player.set_time.assert_called_with(100)
def seek_dvd_test(self):
def test_seek_dvd(self):
"""
Test seeking a DVD
"""
@ -882,7 +882,7 @@ class TestVLCPlayer(TestCase, TestMixin):
mocked_display.vlc_media_player.is_seekable.assert_called_with()
mocked_display.vlc_media_player.set_time.assert_called_with(5000)
def reset_test(self):
def test_reset(self):
"""
Test the reset() method
"""
@ -898,7 +898,7 @@ class TestVLCPlayer(TestCase, TestMixin):
mocked_display.vlc_widget.setVisible.assert_called_with(False)
self.assertEqual(MediaState.Off, vlc_player.get_live_state())
def set_visible_has_own_widget_test(self):
def test_set_visible_has_own_widget(self):
"""
Test the set_visible() method when the player has its own widget
"""
@ -913,7 +913,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# THEN: The media should be stopped and invsibile
mocked_display.vlc_widget.setVisible.assert_called_with(True)
def set_visible_no_widget_test(self):
def test_set_visible_no_widget(self):
"""
Test the set_visible() method when the player doesn't have a widget
"""
@ -929,7 +929,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertEqual(0, mocked_display.vlc_widget.setVisible.call_count)
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def update_ui_test(self, mocked_get_vlc):
def test_update_ui(self, mocked_get_vlc):
"""
Test updating the UI
"""
@ -961,7 +961,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list)
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
def update_ui_dvd_test(self, mocked_get_vlc):
def test_update_ui_dvd(self, mocked_get_vlc):
"""
Test updating the UI for a CD or DVD
"""
@ -995,7 +995,7 @@ class TestVLCPlayer(TestCase, TestMixin):
self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list)
@patch('openlp.core.ui.media.vlcplayer.translate')
def get_info_test(self, mocked_translate):
def test_get_info(self, mocked_translate):
"""
Test that get_info() returns some information about the VLC player
"""

View File

@ -33,7 +33,7 @@ class TestWebkitPlayer(TestCase):
Test the functions in the :mod:`webkitplayer` module.
"""
def check_available_video_disabled_test(self):
def test_check_available_video_disabled(self):
"""
Test of webkit video unavailability
"""
@ -50,7 +50,7 @@ class TestWebkitPlayer(TestCase):
self.assertEqual(False, available,
'The WebkitPlayer should not be available when video feature detection fails')
def check_available_video_enabled_test(self):
def test_check_available_video_enabled(self):
"""
Test of webkit video availability
"""

View File

@ -40,7 +40,7 @@ class TestAlertManager(TestCase):
"""
Registry.create()
def remove_message_text_test(self):
def test_remove_message_text(self):
"""
Test that Alerts are not triggered with empty strings
"""
@ -54,7 +54,7 @@ class TestAlertManager(TestCase):
# THEN: the display should not have been triggered
self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
def trigger_message_text_test(self):
def test_trigger_message_text(self):
"""
Test that Alerts are triggered with a text string
"""
@ -68,7 +68,7 @@ class TestAlertManager(TestCase):
# THEN: the display should have been triggered
self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
def line_break_message_text_test(self):
def test_line_break_message_text(self):
"""
Test that Alerts are triggered with a text string but line breaks are removed
"""

View File

@ -50,7 +50,7 @@ class TestCSVImport(TestCase):
self.registry_patcher.stop()
self.manager_patcher.stop()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the CSV file importer
"""
@ -63,7 +63,7 @@ class TestCSVImport(TestCase):
# THEN: The importer should be an instance of BibleDB
self.assertIsInstance(importer, BibleDB)
def file_import_test(self):
def test_file_import(self):
"""
Test the actual import of CSV Bible file
"""

View File

@ -88,7 +88,7 @@ class TestBSExtract(TestCase):
self.socket_patcher.stop()
self.urllib_patcher.stop()
def get_books_from_http_no_soup_test(self):
def test_get_books_from_http_no_soup(self):
"""
Test the get_books_from_http method when get_soup_for_bible_ref returns a falsey value
"""
@ -112,7 +112,7 @@ class TestBSExtract(TestCase):
'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a '
'false value')
def get_books_from_http_no_content_test(self):
def test_get_books_from_http_no_content(self):
"""
Test the get_books_from_http method when the specified element cannot be found in the tag object returned from
get_soup_for_bible_ref
@ -143,7 +143,7 @@ class TestBSExtract(TestCase):
'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a '
'false value')
def get_books_from_http_content_test(self):
def test_get_books_from_http_content(self):
"""
Test the get_books_from_http method with sample HTML
Also a regression test for bug #1184869. (The anchor tag in the second list item is empty)

View File

@ -33,7 +33,7 @@ class TestLib(TestCase):
"""
Test the functions in the :mod:`lib` module.
"""
def get_reference_separator_test(self):
def test_get_reference_separator(self):
"""
Test the get_reference_separator method
"""
@ -56,7 +56,7 @@ class TestLib(TestCase):
self.assertEqual(separators[key], value)
mocked_update_reference_separators.assert_called_once_with()
def search_results_creation_test(self):
def test_search_results_creation(self):
"""
Test the creation and construction of the SearchResults class
"""
@ -78,7 +78,7 @@ class TestLib(TestCase):
self.assertEqual(search_results.chapter, chapter, 'The chapter should be 1')
self.assertDictEqual(search_results.verse_list, verse_list, 'The verse lists should be identical')
def search_results_has_verse_list_test(self):
def test_search_results_has_verse_list(self):
"""
Test that a SearchResults object with a valid verse list returns True when checking ``has_verse_list()``
"""
@ -91,7 +91,7 @@ class TestLib(TestCase):
# THEN: It should be True
self.assertTrue(has_verse_list, 'The SearchResults object should have a verse list')
def search_results_has_no_verse_list_test(self):
def test_search_results_has_no_verse_list(self):
"""
Test that a SearchResults object with an empty verse list returns False when checking ``has_verse_list()``
"""

View File

@ -42,7 +42,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item = BibleMediaItem(None, MagicMock())
self.setup_application()
def display_results_no_results_test(self):
def test_display_results_no_results(self):
"""
Test the display_results method when called with a single bible, returning no results
"""
@ -64,7 +64,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(self.media_item.search_results, {})
self.assertEqual(self.media_item.second_search_results, {})
def display_results_two_bibles_no_results_test(self):
def test_display_results_two_bibles_no_results(self):
"""
Test the display_results method when called with two bibles, returning no results
"""
@ -87,7 +87,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(self.media_item.search_results, {})
self.assertEqual(self.media_item.second_search_results, {})
def display_results_returns_lots_of_results_test_test(self):
def test_display_results_returns_lots_of_results(self):
"""
Test the display_results method a large number of results (> 100) are returned
"""

View File

@ -50,7 +50,7 @@ class TestOpenSongImport(TestCase):
self.registry_patcher.stop()
self.manager_patcher.stop()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the OpenSong file importer
"""
@ -63,7 +63,7 @@ class TestOpenSongImport(TestCase):
# THEN: The importer should be an instance of BibleDB
self.assertIsInstance(importer, BibleDB)
def file_import_test(self):
def test_file_import(self):
"""
Test the actual import of OpenSong Bible file
"""
@ -93,7 +93,7 @@ class TestOpenSongImport(TestCase):
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, int(verse_tag), verse_text)
def zefania_import_error_test(self):
def test_zefania_import_error(self):
"""
Test that we give an error message if trying to import a zefania bible
"""

View File

@ -50,7 +50,7 @@ class TestOsisImport(TestCase):
self.registry_patcher.stop()
self.manager_patcher.stop()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the OSIS file importer
"""
@ -63,7 +63,7 @@ class TestOsisImport(TestCase):
# THEN: The importer should be an instance of BibleDB
self.assertIsInstance(importer, BibleDB)
def file_import_nested_tags_test(self):
def test_file_import_nested_tags(self):
"""
Test the actual import of OSIS Bible file, with nested chapter and verse tags
"""
@ -93,7 +93,7 @@ class TestOsisImport(TestCase):
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, '1', verse_tag, verse_text)
def file_import_mixed_tags_test(self):
def test_file_import_mixed_tags(self):
"""
Test the actual import of OSIS Bible file, with chapter tags containing milestone verse tags.
"""
@ -123,7 +123,7 @@ class TestOsisImport(TestCase):
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, '1', verse_tag, verse_text)
def file_import_milestone_tags_test(self):
def test_file_import_milestone_tags(self):
"""
Test the actual import of OSIS Bible file, with milestone chapter and verse tags.
"""
@ -153,7 +153,7 @@ class TestOsisImport(TestCase):
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, '1', verse_tag, verse_text)
def file_import_empty_verse_tags_test(self):
def test_file_import_empty_verse_tags(self):
"""
Test the actual import of OSIS Bible file, with an empty verse tags.
"""

View File

@ -25,19 +25,21 @@ This module contains tests for the SWORD Bible importer.
import os
import json
from unittest import TestCase, SkipTest
from unittest import TestCase, skipUnless
from tests.functional import MagicMock, patch
try:
from openlp.plugins.bibles.lib.sword import SwordBible
HAS_PYSWORD = True
except ImportError:
raise SkipTest('PySword is not installed, skipping SWORD test.')
HAS_PYSWORD = False
from openlp.plugins.bibles.lib.db import BibleDB
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', '..', '..', 'resources', 'bibles'))
@skipUnless(HAS_PYSWORD, 'pysword not installed')
class TestSwordImport(TestCase):
"""
Test the functions in the :mod:`swordimport` module.
@ -53,7 +55,7 @@ class TestSwordImport(TestCase):
self.registry_patcher.stop()
self.manager_patcher.stop()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the Sword file importer
"""
@ -69,7 +71,7 @@ class TestSwordImport(TestCase):
@patch('openlp.plugins.bibles.lib.sword.SwordBible.application')
@patch('openlp.plugins.bibles.lib.sword.modules')
@patch('openlp.plugins.bibles.lib.db.BiblesResourcesDB')
def simple_import_test(self, mocked_bible_res_db, mocked_pysword_modules, mocked_application):
def test_simple_import(self, mocked_bible_res_db, mocked_pysword_modules, mocked_application):
"""
Test that a simple SWORD import works
"""

View File

@ -31,7 +31,7 @@ class TestVerseReferenceList(TestCase):
"""
Test the VerseReferenceList class
"""
def add_first_verse_test(self):
def test_add_first_verse(self):
"""
Test the addition of a verse to the empty list
"""
@ -57,7 +57,7 @@ class TestVerseReferenceList(TestCase):
version)
self.assertEqual(reference_list.verse_list[0]['end'], verse, 'The end in first entry should be %u' % verse)
def add_next_verse_test(self):
def test_add_next_verse(self):
"""
Test the addition of the following verse
"""
@ -80,7 +80,7 @@ class TestVerseReferenceList(TestCase):
self.assertEqual(reference_list.verse_list[0]['end'], next_verse,
'The end in first entry should be %u' % next_verse)
def add_another_verse_test(self):
def test_add_another_verse(self):
"""
Test the addition of a verse in another book
"""
@ -103,7 +103,7 @@ class TestVerseReferenceList(TestCase):
# THEN: the current index should be 1
self.assertEqual(reference_list.current_index, 1, 'The current index should be 1')
def add_version_test(self):
def test_add_version(self):
"""
Test the addition of a version to the list
"""
@ -122,7 +122,7 @@ class TestVerseReferenceList(TestCase):
{'version': version, 'copyright': copyright_, 'permission': permission},
'The version data should be appended')
def add_existing_version_test(self):
def test_add_existing_version(self):
"""
Test the addition of an existing version to the list
"""

View File

@ -50,7 +50,7 @@ class TestZefaniaImport(TestCase):
self.registry_patcher.stop()
self.manager_patcher.stop()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the Zefania file importer
"""
@ -63,7 +63,7 @@ class TestZefaniaImport(TestCase):
# THEN: The importer should be an instance of BibleDB
self.assertIsInstance(importer, BibleDB)
def file_import_test(self):
def test_file_import(self):
"""
Test the actual import of Zefania Bible file
"""
@ -93,7 +93,7 @@ class TestZefaniaImport(TestCase):
importer.create_verse.assert_any_call(importer.create_book().id, '1', verse_tag, verse_text)
importer.create_book.assert_any_call('Genesis', 1, 1)
def file_import_no_book_name_test(self):
def test_file_import_no_book_name(self):
"""
Test the import of Zefania Bible file without book names
"""

View File

@ -41,7 +41,7 @@ class TestMediaItem(TestCase, TestMixin):
"""
self.destroy_settings()
def service_load_inactive_test(self):
def test_service_load_inactive(self):
"""
Test the service load in custom with a default service item
"""
@ -54,7 +54,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: the processing should be ignored
self.assertEqual(item, None, 'The Service item is inactive so processing should be bypassed')
def service_load_basic_custom_false_test(self):
def test_service_load_basic_custom_false(self):
"""
Test the service load in custom with a default service item and no requirement to add to the database
"""
@ -77,7 +77,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(self.media_item.create_from_service_item.call_count, 0,
'The item should not have been added to the database')
def service_load_basic_custom_true_test(self):
def test_service_load_basic_custom_true(self):
"""
Test the service load in custom with a default service item and a requirement to add to the database
"""

View File

@ -66,7 +66,7 @@ class TestImageMediaItem(TestCase, TestMixin):
del self.form
self.destroy_settings()
def save_tab_nochange_test_test(self):
def test_save_tab_nochange(self):
"""
Test no changes does not trigger post processing
"""
@ -78,7 +78,7 @@ class TestImageMediaItem(TestCase, TestMixin):
self.assertEqual(0, self.form.settings_form.register_post_process.call_count,
'Image Post processing should not have been requested')
def save_tab_change_test_test(self):
def test_save_tab_change(self):
"""
Test a color change is applied and triggers post processing.
"""

View File

@ -52,7 +52,7 @@ class TestImageMediaItem(TestCase):
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_list')
@patch('openlp.plugins.images.lib.mediaitem.Settings')
def validate_and_load_test(self, mocked_settings, mocked_load_list):
def test_validate_and_load(self, mocked_settings, mocked_load_list):
"""
Test that the validate_and_load_test() method when called without a group
"""
@ -69,7 +69,7 @@ class TestImageMediaItem(TestCase):
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_list')
@patch('openlp.plugins.images.lib.mediaitem.Settings')
def validate_and_load_group_test(self, mocked_settings, mocked_load_list):
def test_validate_and_load_group(self, mocked_settings, mocked_load_list):
"""
Test that the validate_and_load_test() method when called with a group
"""
@ -85,7 +85,7 @@ class TestImageMediaItem(TestCase):
mocked_settings().setValue.assert_called_once_with(ANY, '/path1')
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def save_new_images_list_empty_list_test(self, mocked_load_full_list):
def test_save_new_images_list_empty_list(self, mocked_load_full_list):
"""
Test that the save_new_images_list() method handles empty lists gracefully
"""
@ -101,7 +101,7 @@ class TestImageMediaItem(TestCase):
'The save_object() method should not have been called')
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def save_new_images_list_single_image_with_reload_test(self, mocked_load_full_list):
def test_save_new_images_list_single_image_with_reload(self, mocked_load_full_list):
"""
Test that the save_new_images_list() calls load_full_list() when reload_list is set to True
"""
@ -120,7 +120,7 @@ class TestImageMediaItem(TestCase):
delattr(ImageFilenames, 'filename')
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def save_new_images_list_single_image_without_reload_test(self, mocked_load_full_list):
def test_save_new_images_list_single_image_without_reload(self, mocked_load_full_list):
"""
Test that the save_new_images_list() doesn't call load_full_list() when reload_list is set to False
"""
@ -135,7 +135,7 @@ class TestImageMediaItem(TestCase):
self.assertEquals(mocked_load_full_list.call_count, 0, 'load_full_list() should not have been called')
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def save_new_images_list_multiple_images_test(self, mocked_load_full_list):
def test_save_new_images_list_multiple_images(self, mocked_load_full_list):
"""
Test that the save_new_images_list() saves all images in the list
"""
@ -151,7 +151,7 @@ class TestImageMediaItem(TestCase):
'load_full_list() should have been called three times')
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def save_new_images_list_other_objects_in_list_test(self, mocked_load_full_list):
def test_save_new_images_list_other_objects_in_list(self, mocked_load_full_list):
"""
Test that the save_new_images_list() ignores everything in the provided list except strings
"""
@ -166,7 +166,7 @@ class TestImageMediaItem(TestCase):
self.assertEquals(self.media_item.manager.save_object.call_count, 2,
'load_full_list() should have been called only once')
def on_reset_click_test(self):
def test_on_reset_click(self):
"""
Test that on_reset_click() actually resets the background
"""
@ -181,7 +181,7 @@ class TestImageMediaItem(TestCase):
self.media_item.live_controller.display.reset_image.assert_called_with()
@patch('openlp.plugins.images.lib.mediaitem.delete_file')
def recursively_delete_group_test(self, mocked_delete_file):
def test_recursively_delete_group(self, mocked_delete_file):
"""
Test that recursively_delete_group() works
"""
@ -233,7 +233,7 @@ class TestImageMediaItem(TestCase):
@patch('openlp.plugins.images.lib.mediaitem.delete_file')
@patch('openlp.plugins.images.lib.mediaitem.check_item_selected')
def on_delete_click_test(self, mocked_check_item_selected, mocked_delete_file):
def test_on_delete_click(self, mocked_check_item_selected, mocked_delete_file):
"""
Test that on_delete_click() works
"""
@ -257,7 +257,7 @@ class TestImageMediaItem(TestCase):
# THEN: delete_file should have been called twice
self.assertEquals(mocked_delete_file.call_count, 2, 'delete_file() should have been called twice')
def create_item_from_id_test(self):
def test_create_item_from_id(self):
"""
Test that the create_item_from_id() method returns a valid QTreeWidgetItem with a pre-created ImageFilenames
"""

View File

@ -40,7 +40,7 @@ class MediaPluginTest(TestCase, TestMixin):
@patch(u'openlp.plugins.media.mediaplugin.Plugin.initialise')
@patch(u'openlp.plugins.media.mediaplugin.Settings')
def initialise_test(self, _mocked_settings, mocked_initialise):
def test_initialise(self, _mocked_settings, mocked_initialise):
"""
Test that the initialise() method overwrites the built-in one, but still calls it
"""
@ -65,7 +65,7 @@ class MediaPluginTest(TestCase, TestMixin):
self.assertNotEquals(len(MediaPlugin.about()), 0)
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
def process_check_binary_pass_test(self, mocked_checked_binary_exists):
def test_process_check_binary_pass(self, mocked_checked_binary_exists):
"""
Test that the Process check returns true if found
"""
@ -78,7 +78,7 @@ class MediaPluginTest(TestCase, TestMixin):
self.assertTrue(result, 'Mediainfo should have been found')
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
def process_check_binary_fail_test(self, mocked_checked_binary_exists):
def test_process_check_binary_fail(self, mocked_checked_binary_exists):
"""
Test that the Process check returns false if not found
"""

View File

@ -59,7 +59,7 @@ class TestImpressController(TestCase, TestMixin):
self.destroy_settings()
shutil.rmtree(self.temp_folder)
def constructor_test(self):
def test_constructor(self):
"""
Test the Constructor from the ImpressController
"""
@ -86,7 +86,7 @@ class TestImpressDocument(TestCase):
self.ppc = ImpressController(mocked_plugin)
self.doc = ImpressDocument(self.ppc, self.file_name)
def create_titles_and_notes_test(self):
def test_create_titles_and_notes(self):
"""
Test ImpressDocument.create_titles_and_notes
"""
@ -114,7 +114,7 @@ class TestImpressDocument(TestCase):
# two arrays of two elements
self.doc.save_titles_and_notes.assert_called_once_with(['\n', '\n'], [' ', ' '])
def get_text_from_page_out_of_bound_test(self):
def test_get_text_from_page_out_of_bound(self):
"""
Test ImpressDocument.__get_text_from_page with out-of-bounds index
"""
@ -143,7 +143,7 @@ class TestImpressDocument(TestCase):
self.assertEqual(self.doc.document.getDrawPages().getByIndex.call_count, 0,
'There should be no call to getByIndex')
def get_text_from_page_wrong_type_test(self):
def test_get_text_from_page_wrong_type(self):
"""
Test ImpressDocument.__get_text_from_page with wrong TextType
"""
@ -159,7 +159,7 @@ class TestImpressDocument(TestCase):
self.assertEqual(self.doc.document.getDrawPages().getByIndex.call_count, 0,
'There should be no call to getByIndex')
def get_text_from_page_valid_params_test(self):
def test_get_text_from_page_valid_params(self):
"""
Test ImpressDocument.__get_text_from_page with valid parameters
"""

View File

@ -46,7 +46,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item = PresentationMediaItem(None, MagicMock, MagicMock())
self.setup_application()
def build_file_mask_string_test(self):
def test_build_file_mask_string(self):
"""
Test the build_file_mask_string() method
"""
@ -85,7 +85,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertIn('*.xps', self.media_item.on_new_file_masks, 'The file mask should contain the xps extension')
self.assertIn('*.oxps', self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension')
def clean_up_thumbnails_test(self):
def test_clean_up_thumbnails(self):
"""
Test that the clean_up_thumbnails method works as expected when files exists.
"""
@ -110,7 +110,7 @@ class TestMediaItem(TestCase, TestMixin):
# the presentation_file's mtime.
mocked_doc.assert_has_calls([call.get_thumbnail_path(1, True), call.presentation_deleted()], True)
def clean_up_thumbnails_missing_file_test(self):
def test_clean_up_thumbnails_missing_file(self):
"""
Test that the clean_up_thumbnails method works as expected when file is missing.
"""

View File

@ -47,7 +47,7 @@ class TestMessageListener(TestCase, TestMixin):
self.media_item = PresentationMediaItem(None, MagicMock, MagicMock())
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def start_presentation_test(self, media_mock):
def test_start_presentation(self, media_mock):
"""
Find and chose a controller to play a presentations.
"""
@ -75,7 +75,7 @@ class TestMessageListener(TestCase, TestMixin):
self.assertTrue(len(controllers), 'We have loaded a controller')
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def start_presentation_with_no_player_test(self, media_mock):
def test_start_presentation_with_no_player(self, media_mock):
"""
Find and chose a controller to play a presentations when the player is not available.
"""
@ -107,7 +107,7 @@ class TestMessageListener(TestCase, TestMixin):
self.assertTrue(len(controllers), 'We have loaded a controller')
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def start_pdf_presentation_test(self, media_mock):
def test_start_pdf_presentation(self, media_mock):
"""
Test the startup of pdf presentation succeed.
"""
@ -132,7 +132,7 @@ class TestController(TestCase, TestMixin):
Test the Presentation Controller.
"""
def add_handler_failure_test(self):
def test_add_handler_failure(self):
"""
Test that add_handler does set doc.slidenumber to 0 in case filed loading
"""

View File

@ -78,7 +78,7 @@ class TestPdfController(TestCase, TestMixin):
shutil.rmtree(self.thumbnail_folder)
shutil.rmtree(self.temp_folder)
def constructor_test(self):
def test_constructor(self):
"""
Test the Constructor from the PdfController
"""
@ -91,7 +91,7 @@ class TestPdfController(TestCase, TestMixin):
# THEN: The name of the presentation controller should be correct
self.assertEqual('Pdf', controller.name, 'The name of the presentation controller should be correct')
def load_pdf_test(self):
def test_load_pdf(self):
"""
Test loading of a Pdf using the PdfController
"""
@ -111,7 +111,7 @@ class TestPdfController(TestCase, TestMixin):
self.assertTrue(loaded, 'The loading of the PDF should succeed.')
self.assertEqual(3, document.get_slide_count(), 'The pagecount of the PDF should be 3.')
def load_pdf_pictures_test(self):
def test_load_pdf_pictures(self):
"""
Test loading of a Pdf and check size of generate pictures
"""
@ -139,7 +139,7 @@ class TestPdfController(TestCase, TestMixin):
self.assertEqual(543, image.width(), 'The width should be 543')
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def process_check_binary_mudraw_test(self, mocked_check_binary_exists):
def test_process_check_binary_mudraw(self, mocked_check_binary_exists):
"""
Test that the correct output from mudraw is detected
"""
@ -157,7 +157,7 @@ class TestPdfController(TestCase, TestMixin):
self.assertEqual('mudraw', ret, 'mudraw should have been detected')
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def process_check_binary_new_motool_test(self, mocked_check_binary_exists):
def test_process_check_binary_new_motool(self, mocked_check_binary_exists):
"""
Test that the correct output from the new mutool is detected
"""
@ -177,7 +177,7 @@ class TestPdfController(TestCase, TestMixin):
self.assertEqual('mutool', ret, 'mutool should have been detected')
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def process_check_binary_old_motool_test(self, mocked_check_binary_exists):
def test_process_check_binary_old_motool(self, mocked_check_binary_exists):
"""
Test that the output from the old mutool is not accepted
"""
@ -194,7 +194,7 @@ class TestPdfController(TestCase, TestMixin):
self.assertIsNone(ret, 'old mutool should not be accepted!')
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def process_check_binary_gs_test(self, mocked_check_binary_exists):
def test_process_check_binary_gs(self, mocked_check_binary_exists):
"""
Test that the correct output from gs is detected
"""

View File

@ -65,7 +65,7 @@ class TestPowerpointController(TestCase, TestMixin):
self.destroy_settings()
shutil.rmtree(self.temp_folder)
def constructor_test(self):
def test_constructor(self):
"""
Test the Constructor from the PowerpointController
"""
@ -120,7 +120,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
self.destroy_settings()
shutil.rmtree(self.temp_folder)
def show_error_msg_test(self):
def test_show_error_msg(self):
"""
Test the PowerpointDocument.show_error_msg() method gets called on com exception
"""
@ -160,7 +160,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
else:
self.skipTest('Powerpoint not available, skipping test.')
def create_titles_and_notes_test(self):
def test_create_titles_and_notes(self):
"""
Test creating the titles from PowerPoint
"""
@ -183,7 +183,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
# THEN the save should have been called exactly once with 2 titles and 2 notes
self.doc.save_titles_and_notes.assert_called_once_with(['SlideText\n', 'SlideText\n'], [' ', ' '])
def create_titles_and_notes_with_no_slides_test(self):
def test_create_titles_and_notes_with_no_slides(self):
"""
Test creating the titles from PowerPoint when it returns no slides
"""
@ -201,7 +201,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
# THEN the save should have been called exactly once with empty titles and notes
doc.save_titles_and_notes.assert_called_once_with([], [])
def get_text_from_shapes_test(self):
def test_get_text_from_shapes(self):
"""
Test getting text from powerpoint shapes
"""
@ -218,7 +218,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
# THEN: it should return the text
self.assertEqual(result, 'slideText\nslideText\n', 'result should match \'slideText\nslideText\n\'')
def get_text_from_shapes_with_no_shapes_test(self):
def test_get_text_from_shapes_with_no_shapes(self):
"""
Test getting text from powerpoint shapes with no shapes
"""
@ -231,7 +231,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
# THEN: it should not fail but return empty string
self.assertEqual(result, '', 'result should be empty')
def goto_slide_test(self):
def test_goto_slide(self):
"""
Test that goto_slide goes to next effect if the slide is already displayed
"""
@ -251,7 +251,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
# THEN: next_step() should be call to try to advance to the next effect.
self.assertTrue(doc.next_step.called, 'next_step() should have been called!')
def blank_screen_test(self):
def test_blank_screen(self):
"""
Test that blank_screen works as expected
"""
@ -271,7 +271,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
self.assertEquals(doc.blank_slide, 2, 'doc.blank_slide should be 2 because of the PowerPoint version')
self.assertEquals(doc.blank_click, 3, 'doc.blank_click should be 3 because of the PowerPoint version')
def unblank_screen_test(self):
def test_unblank_screen(self):
"""
Test that unblank_screen works as expected
"""

View File

@ -65,7 +65,7 @@ class TestPptviewController(TestCase, TestMixin):
self.destroy_settings()
shutil.rmtree(self.temp_folder)
def constructor_test(self):
def test_constructor(self):
"""
Test the Constructor from the PptViewController
"""
@ -79,7 +79,7 @@ class TestPptviewController(TestCase, TestMixin):
self.assertEqual('Powerpoint Viewer', controller.name,
'The name of the presentation controller should be correct')
def check_available_test(self):
def test_check_available(self):
"""
Test check_available / check_installed
"""
@ -162,7 +162,7 @@ class TestPptviewDocument(TestCase):
self.screen_list_patcher.stop()
shutil.rmtree(self.temp_folder)
def load_presentation_succesfull_test(self):
def test_load_presentation_succesfull(self):
"""
Test the PptviewDocument.load_presentation() method when the PPT is successfully opened
"""
@ -181,7 +181,7 @@ class TestPptviewDocument(TestCase):
# THEN: PptviewDocument.load_presentation should return True
self.assertTrue(result)
def load_presentation_un_succesfull_test(self):
def test_load_presentation_un_succesfull(self):
"""
Test the PptviewDocument.load_presentation() method when the temporary directory does not exist and the PPT is
not successfully opened
@ -202,7 +202,7 @@ class TestPptviewDocument(TestCase):
mock_makedirs.assert_called_once_with(self.temp_folder)
self.assertFalse(result)
def create_titles_and_notes_test(self):
def test_create_titles_and_notes(self):
"""
Test PowerpointController.create_titles_and_notes
"""
@ -219,7 +219,7 @@ class TestPptviewDocument(TestCase):
['Notes for slide 1', 'Inserted', 'Notes for slide 2',
'Notes \nfor slide 4', 'Notes for slide 3'])
def create_titles_and_notes_nonexistent_file_test(self):
def test_create_titles_and_notes_nonexistent_file(self):
"""
Test PowerpointController.create_titles_and_notes with nonexistent file
"""
@ -242,7 +242,7 @@ class TestPptviewDocument(TestCase):
mocked_exists.assert_any_call('Idontexist.pptx')
self.assertEqual(mocked_open.call_count, 0, 'There should be no calls to open a file.')
def create_titles_and_notes_invalid_file_test(self):
def test_create_titles_and_notes_invalid_file(self):
"""
Test PowerpointController.create_titles_and_notes with invalid file
"""

View File

@ -60,7 +60,7 @@ class TestPresentationController(TestCase):
def tearDown(self):
self.get_thumbnail_folder_patcher.stop()
def constructor_test(self):
def test_constructor(self):
"""
Test the Constructor
"""
@ -72,7 +72,7 @@ class TestPresentationController(TestCase):
self.assertEqual('PresentationController', self.presentation.name,
'The name of the presentation controller should be correct')
def save_titles_and_notes_test(self):
def test_save_titles_and_notes(self):
"""
Test PresentationDocument.save_titles_and_notes method with two valid lists
"""
@ -95,7 +95,7 @@ class TestPresentationController(TestCase):
mocked_open().write.assert_any_call('one')
mocked_open().write.assert_any_call('two')
def save_titles_and_notes_with_None_test(self):
def test_save_titles_and_notes_with_None(self):
"""
Test PresentationDocument.save_titles_and_notes method with no data
"""
@ -111,7 +111,7 @@ class TestPresentationController(TestCase):
# THEN: No file should have been created
self.assertEqual(mocked_open.call_count, 0, 'No file should be created')
def get_titles_and_notes_test(self):
def test_get_titles_and_notes(self):
"""
Test PresentationDocument.get_titles_and_notes method
"""
@ -137,7 +137,7 @@ class TestPresentationController(TestCase):
mocked_open.assert_any_call(os.path.join('test', 'slideNotes2.txt'), encoding='utf-8')
self.assertEqual(mocked_exists.call_count, 3, 'Three files should have been checked')
def get_titles_and_notes_with_file_not_found_test(self):
def test_get_titles_and_notes_with_file_not_found(self):
"""
Test PresentationDocument.get_titles_and_notes method with file not found
"""
@ -159,7 +159,7 @@ class TestPresentationController(TestCase):
self.assertEqual(mocked_open.call_count, 0, 'No calls to open files')
self.assertEqual(mocked_exists.call_count, 1, 'There should be one call to file exists')
def get_titles_and_notes_with_file_error_test(self):
def test_get_titles_and_notes_with_file_error(self):
"""
Test PresentationDocument.get_titles_and_notes method with file errors
"""
@ -238,7 +238,7 @@ class TestPresentationDocument(TestCase):
self.os_patcher.stop()
self._setup_patcher.stop()
def initialise_presentation_document_test(self):
def test_initialise_presentation_document(self):
"""
Test the PresentationDocument __init__ method when initialising the PresentationDocument Class
"""
@ -251,7 +251,7 @@ class TestPresentationDocument(TestCase):
# THEN: PresentationDocument._setup should have been called with the argument 'Name'
self.mock_setup.assert_called_once_with('Name')
def presentation_document_setup_test(self):
def test_presentation_document_setup(self):
"""
Test the PresentationDocument _setup method when initialising the PresentationDocument Class
"""
@ -267,7 +267,7 @@ class TestPresentationDocument(TestCase):
self._setup_patcher.start()
def load_presentation_test(self):
def test_load_presentation(self):
"""
Test the PresentationDocument.load_presentation method.
"""
@ -281,7 +281,7 @@ class TestPresentationDocument(TestCase):
# THEN: load_presentation should return false
self.assertFalse(result, "PresentationDocument.load_presentation should return false.")
def get_file_name_test(self):
def test_get_file_name(self):
"""
Test the PresentationDocument.get_file_name method.
"""

View File

@ -71,7 +71,7 @@ class TestRemoteTab(TestCase, TestMixin):
del self.form
self.destroy_settings()
def get_ip_address_default_test(self):
def test_get_ip_address_default(self):
"""
Test the get_ip_address function with ZERO_URL
"""
@ -81,7 +81,7 @@ class TestRemoteTab(TestCase, TestMixin):
self.assertTrue(re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address),
'The return value should be a valid ip address')
def get_ip_address_with_ip_test(self):
def test_get_ip_address_with_ip(self):
"""
Test the get_ip_address function with given ip address
"""
@ -93,7 +93,7 @@ class TestRemoteTab(TestCase, TestMixin):
# THEN: the default ip address will be returned
self.assertEqual(ip_address, given_ip, 'The return value should be %s' % given_ip)
def set_basic_urls_test(self):
def test_set_basic_urls(self):
"""
Test the set_urls function with standard defaults
"""
@ -121,7 +121,7 @@ class TestRemoteTab(TestCase, TestMixin):
self.assertEqual(self.form.user_login_group_box.isChecked(), False,
'The authentication box should not be enabled')
def set_certificate_urls_test(self):
def test_set_certificate_urls(self):
"""
Test the set_urls function with certificate available
"""

View File

@ -67,7 +67,7 @@ class TestRouter(TestCase, TestMixin):
"""
self.destroy_settings()
def password_encrypter_test(self):
def test_password_encrypter(self):
"""
Test hash userid and password function
"""
@ -84,7 +84,7 @@ class TestRouter(TestCase, TestMixin):
self.assertEqual(router.auth, test_value,
'The result for make_sha_hash should return the correct encrypted password')
def process_http_request_test(self):
def test_process_http_request(self):
"""
Test the router control functionality
"""
@ -103,7 +103,7 @@ class TestRouter(TestCase, TestMixin):
self.assertEqual(mocked_function, function['function'], 'The mocked function should match defined value.')
self.assertFalse(function['secure'], 'The mocked function should not require any security.')
def process_secure_http_request_test(self):
def test_process_secure_http_request(self):
"""
Test the router control functionality
"""
@ -131,7 +131,7 @@ class TestRouter(TestCase, TestMixin):
self.router.send_response.assert_called_once_with(401)
self.assertEqual(self.router.send_header.call_count, 5, 'The header should have been called five times.')
def get_content_type_test(self):
def test_get_content_type(self):
"""
Test the get_content_type logic
"""
@ -151,7 +151,7 @@ class TestRouter(TestCase, TestMixin):
# THEN: all types should match
self.assertEqual(content_type, header[1], 'Mismatch of content type')
def main_poll_test(self):
def test_main_poll(self):
"""
Test the main poll logic
"""
@ -171,7 +171,7 @@ class TestRouter(TestCase, TestMixin):
self.assertEqual(results.decode('utf-8'), '{"results": {"slide_count": 2}}',
'The resulting json strings should match')
def serve_file_without_params_test(self):
def test_serve_file_without_params(self):
"""
Test the serve_file method without params
"""
@ -190,7 +190,7 @@ class TestRouter(TestCase, TestMixin):
self.router.send_response.assert_called_once_with(404)
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
def serve_file_with_valid_params_test(self):
def test_serve_file_with_valid_params(self):
"""
Test the serve_file method with an existing file
"""
@ -213,7 +213,7 @@ class TestRouter(TestCase, TestMixin):
self.router.send_header.assert_called_once_with('Content-type', 'text/html')
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
def serve_file_with_partial_params_test(self):
def test_serve_file_with_partial_params(self):
"""
Test the serve_file method with an existing file
"""
@ -236,7 +236,7 @@ class TestRouter(TestCase, TestMixin):
self.router.send_header.assert_called_once_with('Content-type', 'text/html')
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
def serve_thumbnail_without_params_test(self):
def test_serve_thumbnail_without_params(self):
"""
Test the serve_thumbnail routine without params
"""
@ -254,7 +254,7 @@ class TestRouter(TestCase, TestMixin):
self.assertEqual(self.router.send_response.call_count, 1, 'Send response should be called once')
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers should be called once')
def serve_thumbnail_with_invalid_params_test(self):
def test_serve_thumbnail_with_invalid_params(self):
"""
Test the serve_thumbnail routine with invalid params
"""
@ -287,7 +287,7 @@ class TestRouter(TestCase, TestMixin):
# THEN: return a 404
self.router.send_response.assert_called_once_with(404)
def serve_thumbnail_with_valid_params_test(self):
def test_serve_thumbnail_with_valid_params(self):
"""
Test the serve_thumbnail routine with valid params
"""
@ -326,7 +326,7 @@ class TestRouter(TestCase, TestMixin):
'slide1.png')),
'slide1.png', width, height)
def remote_next_test(self):
def test_remote_next(self):
"""
Test service manager receives remote next click properly (bug 1407445)
"""
@ -347,7 +347,7 @@ class TestRouter(TestCase, TestMixin):
# THEN: service_manager.next_item() should have been called
self.assertTrue(mocked_next_item.called, 'next_item() should have been called in service_manager')
def remote_previous_test(self):
def test_remote_previous(self):
"""
Test service manager receives remote previous click properly (bug 1407445)
"""
@ -368,7 +368,7 @@ class TestRouter(TestCase, TestMixin):
# THEN: service_manager.next_item() should have been called
self.assertTrue(mocked_previous_item.called, 'previous_item() should have been called in service_manager')
def remote_stage_personal_html_test(self):
def test_remote_stage_personal_html(self):
"""
Test the stage url with a parameter after loaded a url/stage.html file
"""
@ -386,7 +386,7 @@ class TestRouter(TestCase, TestMixin):
# THEN: we should use the specific stage file instance
self.router._process_file.assert_called_with(os.path.join('trb', 'stage.html'))
def remote_stage_personal_css_test(self):
def test_remote_stage_personal_css(self):
"""
Test the html with reference stages/trb/trb.css then loaded a stages/trb/trb.css file
"""

View File

@ -57,7 +57,7 @@ class TestEditSongForm(TestCase, TestMixin):
"""
self.destroy_settings()
def validate_matching_tags_test(self):
def test_validate_matching_tags(self):
# Given a set of tags
tags = ['{r}', '{/r}', '{bl}', '{/bl}', '{su}', '{/su}']
@ -67,7 +67,7 @@ class TestEditSongForm(TestCase, TestMixin):
# THEN they should be valid
self.assertTrue(valid, "The tags list should be valid")
def validate_nonmatching_tags_test(self):
def test_validate_nonmatching_tags(self):
# Given a set of tags
tags = ['{r}', '{/r}', '{bl}', '{/bl}', '{br}', '{su}', '{/su}']

View File

@ -53,7 +53,7 @@ class TestEditVerseForm(TestCase, TestMixin):
"""
self.destroy_settings()
def update_suggested_verse_number_test(self):
def test_update_suggested_verse_number(self):
"""
Test that update_suggested_verse_number() has no effect when editing a single verse
"""

View File

@ -153,7 +153,7 @@ class TestEasyWorshipSongImport(TestCase):
"""
Registry.create()
def create_field_desc_entry_test(self):
def test_create_field_desc_entry(self):
"""
Test creating an instance of the :class`FieldDescEntry` class.
"""
@ -172,7 +172,7 @@ class TestEasyWorshipSongImport(TestCase):
'FieldDescEntry.type should be the same as the type argument')
self.assertEqual(field_desc_entry.size, size, 'FieldDescEntry.size should be the same as the size argument')
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the EasyWorship file importer
"""
@ -186,7 +186,7 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
def find_field_exists_test(self):
def test_find_field_exists(self):
"""
Test finding an existing field in a given list using the :mod:`find_field`
"""
@ -204,7 +204,7 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: The item corresponding the index returned should have the same name attribute
self.assertEqual(importer.field_descriptions[importer.find_field(field_name)].name, field_name)
def find_non_existing_field_test(self):
def test_find_non_existing_field(self):
"""
Test finding an non-existing field in a given list using the :mod:`find_field`
"""
@ -221,7 +221,7 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: The importer object should not be None
self.assertRaises(IndexError, importer.find_field, field_name)
def set_record_struct_test(self):
def test_set_record_struct(self):
"""
Test the :mod:`set_record_struct` module
"""
@ -240,7 +240,7 @@ class TestEasyWorshipSongImport(TestCase):
self.assertIsNone(return_value, 'set_record_struct should return None')
mocked_struct.Struct.assert_called_with('>50sHIB250s250s10sQ')
def get_field_test(self):
def test_get_field(self):
"""
Test the :mod:`get_field` module
"""
@ -262,7 +262,7 @@ class TestEasyWorshipSongImport(TestCase):
'get_field should return "%s" when called with "%s"' %
(result, TEST_FIELDS[field_index]))
def get_memo_field_test(self):
def test_get_memo_field(self):
"""
Test the :mod:`get_field` module
"""
@ -294,7 +294,7 @@ class TestEasyWorshipSongImport(TestCase):
else:
mocked_memo_file.seek.assert_any_call(call[0], call[1])
def do_import_source_test(self):
def test_do_import_source(self):
"""
Test the :mod:`do_import` module opens the correct files
"""
@ -313,7 +313,7 @@ class TestEasyWorshipSongImport(TestCase):
mocked_os_path.isfile.assert_any_call('Songs.DB')
mocked_os_path.isfile.assert_any_call('Songs.MB')
def do_import_source_invalid_test(self):
def test_do_import_source_invalid(self):
"""
Test the :mod:`do_import` module produces an error when Songs.MB not found.
"""
@ -333,7 +333,7 @@ class TestEasyWorshipSongImport(TestCase):
importer.log_error.assert_any_call(importer.import_source, 'Could not find the "Songs.MB" file. It must be '
'in the same folder as the "Songs.DB" file.')
def do_import_database_validity_test(self):
def test_do_import_database_validity(self):
"""
Test the :mod:`do_import` module handles invalid database files correctly
"""
@ -352,7 +352,7 @@ class TestEasyWorshipSongImport(TestCase):
self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
mocked_os_path.getsize.assert_any_call('Songs.DB')
def do_import_memo_validty_test(self):
def test_do_import_memo_validty(self):
"""
Test the :mod:`do_import` module handles invalid memo files correctly
"""
@ -379,7 +379,7 @@ class TestEasyWorshipSongImport(TestCase):
mocked_open().close.reset_mock()
self.assertIs(mocked_open().seek.called, False, 'db_file.seek should not have been called.')
def code_page_to_encoding_test(self):
def test_code_page_to_encoding(self):
"""
Test the :mod:`do_import` converts the code page to the encoding correctly
"""
@ -405,7 +405,7 @@ class TestEasyWorshipSongImport(TestCase):
self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
mocked_retrieve_windows_encoding.assert_any_call(encoding)
def db_file_import_test(self):
def test_db_file_import(self):
"""
Test the actual import of real song database files and check that the imported data is correct.
"""
@ -461,7 +461,7 @@ class TestEasyWorshipSongImport(TestCase):
'verse_order_list for %s should be %s' % (title, verse_order_list))
mocked_finish.assert_called_with()
def ews_file_import_test(self):
def test_ews_file_import(self):
"""
Test the actual import of song from ews file and check that the imported data is correct.
"""
@ -502,7 +502,7 @@ class TestEasyWorshipSongImport(TestCase):
mocked_add_verse.assert_any_call(verse_text, verse_tag)
mocked_finish.assert_called_with()
def import_rtf_unescaped_unicode_test(self):
def test_import_rtf_unescaped_unicode(self):
"""
Test import of rtf without the expected escaping of unicode
"""

View File

@ -107,7 +107,7 @@ class TestFoilPresenter(TestCase):
self.song_xml_patcher.stop()
self.translate_patcher.stop()
def create_foil_presenter_test(self):
def test_create_foil_presenter(self):
"""
Test creating an instance of the foil_presenter class
"""
@ -121,7 +121,7 @@ class TestFoilPresenter(TestCase):
# THEN: The instance should not be None
self.assertIsNotNone(foil_presenter_instance, 'foil_presenter instance should not be none')
def no_xml_test(self):
def test_no_xml(self):
"""
Test calling xml_to_song with out the xml argument
"""
@ -137,7 +137,7 @@ class TestFoilPresenter(TestCase):
# Then: xml_to_song should return False
self.assertEqual(result, None, 'xml_to_song should return None when called with %s' % arg)
def encoding_declaration_removal_test(self):
def test_encoding_declaration_removal(self):
"""
Test that the encoding declaration is removed
"""
@ -151,7 +151,7 @@ class TestFoilPresenter(TestCase):
# THEN: the xml encoding declaration should have been stripped
self.mocked_re.compile.sub.called_with('\n<foilpresenterfolie>')
def no_encoding_declaration_test(self):
def test_no_encoding_declaration(self):
"""
Check that the xml sting is left intact when no encoding declaration is made
"""
@ -165,7 +165,7 @@ class TestFoilPresenter(TestCase):
# THEN: the string should have been left intact
self.mocked_re.compile.sub.called_with('<foilpresenterfolie>')
def process_lyrics_no_verses_test(self):
def test_process_lyrics_no_verses(self):
"""
Test that _process_lyrics handles song files that have no verses.
"""

View File

@ -52,7 +52,7 @@ class TestLib(TestCase):
old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it
some day for a crown'''
def clean_string_test(self):
def test_clean_string(self):
"""
Test the clean_string() function
"""
@ -65,7 +65,7 @@ class TestLib(TestCase):
# THEN: The string should be cleaned up and lower-cased
self.assertEqual(result, 'aint gonna find you there ', 'The string should be cleaned up properly')
def clean_title_test(self):
def test_clean_title(self):
"""
Test the clean_title() function
"""
@ -78,7 +78,7 @@ class TestLib(TestCase):
# THEN: The string should be cleaned up
self.assertEqual(result, 'This is a dirty string', 'The title should be cleaned up properly: "%s"' % result)
def songs_probably_equal_same_song_test(self):
def test_songs_probably_equal_same_song(self):
"""
Test the songs_probably_equal function with twice the same song.
"""
@ -92,7 +92,7 @@ class TestLib(TestCase):
# THEN: The result should be a tuple..
assert result == (2, 4), 'The result should be the tuble of song positions'
def songs_probably_equal_short_song_test(self):
def test_songs_probably_equal_short_song(self):
"""
Test the songs_probably_equal function with a song and a shorter version of the same song.
"""
@ -106,7 +106,7 @@ class TestLib(TestCase):
# THEN: The result should be a tuple..
assert result == (1, 3), 'The result should be the tuble of song positions'
def songs_probably_equal_error_song_test(self):
def test_songs_probably_equal_error_song(self):
"""
Test the songs_probably_equal function with a song and a very erroneous version of the same song.
"""
@ -120,7 +120,7 @@ class TestLib(TestCase):
# THEN: The result should be a tuple of song positions.
assert result == (4, 7), 'The result should be the tuble of song positions'
def songs_probably_equal_different_song_test(self):
def test_songs_probably_equal_different_song(self):
"""
Test the songs_probably_equal function with two different songs.
"""
@ -134,7 +134,7 @@ class TestLib(TestCase):
# THEN: The result should be None.
assert result is None, 'The result should be None'
def remove_typos_beginning_test(self):
def test_remove_typos_beginning(self):
"""
Test the _remove_typos function with a typo at the beginning.
"""
@ -148,7 +148,7 @@ class TestLib(TestCase):
assert len(result) == 1, 'The result should contain only one element.'
assert result[0][0] == 'equal', 'The result should contain an equal element.'
def remove_typos_beginning_negated_test(self):
def test_remove_typos_beginning_negated(self):
"""
Test the _remove_typos function with a large difference at the beginning.
"""
@ -161,7 +161,7 @@ class TestLib(TestCase):
# THEN: There diff should not have changed.
assert result == diff
def remove_typos_end_test(self):
def test_remove_typos_end(self):
"""
Test the _remove_typos function with a typo at the end.
"""
@ -175,7 +175,7 @@ class TestLib(TestCase):
assert len(result) == 1, 'The result should contain only one element.'
assert result[0][0] == 'equal', 'The result should contain an equal element.'
def remove_typos_end_negated_test(self):
def test_remove_typos_end_negated(self):
"""
Test the _remove_typos function with a large difference at the end.
"""
@ -188,7 +188,7 @@ class TestLib(TestCase):
# THEN: There diff should not have changed.
assert result == diff
def remove_typos_middle_test(self):
def test_remove_typos_middle(self):
"""
Test the _remove_typos function with a typo in the middle.
"""
@ -206,7 +206,7 @@ class TestLib(TestCase):
assert result[0][3] == 0, 'The start indices should be kept.'
assert result[0][4] == 21, 'The stop indices should be kept.'
def remove_typos_beginning_negated_test(self):
def test_remove_typos_beginning_negated(self):
"""
Test the _remove_typos function with a large difference in the middle.
"""
@ -219,7 +219,7 @@ class TestLib(TestCase):
# THEN: There diff should not have changed.
assert result == diff
def op_length_test(self):
def test_op_length(self):
"""
Test the _op_length function.
"""
@ -232,7 +232,7 @@ class TestLib(TestCase):
# THEN: The maximum length should be returned.
assert result == 10, 'The length should be 10.'
def strip_rtf_charsets_test(self):
def test_strip_rtf_charsets(self):
"""
Test that the strip_rtf() method properly decodes the supported charsets.
"""
@ -270,7 +270,7 @@ class TestVerseType(TestCase):
This is a test case to test various methods in the VerseType enumeration class.
"""
def translated_tag_test(self):
def test_translated_tag(self):
"""
Test that the translated_tag() method returns the correct tags
"""
@ -290,7 +290,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "C"
self.assertEqual(result, 'C', 'The result should be "C"')
def translated_invalid_tag_test(self):
def test_translated_invalid_tag(self):
"""
Test that the translated_tag() method returns the default tag when passed an invalid tag
"""
@ -304,7 +304,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "O"
self.assertEqual(result, 'O', 'The result should be "O", but was "%s"' % result)
def translated_invalid_tag_with_specified_default_test(self):
def test_translated_invalid_tag_with_specified_default(self):
"""
Test that the translated_tag() method returns the specified default tag when passed an invalid tag
"""
@ -318,7 +318,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "B"
self.assertEqual(result, 'B', 'The result should be "B", but was "%s"' % result)
def translated_invalid_tag_with_invalid_default_test(self):
def test_translated_invalid_tag_with_invalid_default(self):
"""
Test that the translated_tag() method returns a sane default tag when passed an invalid default
"""
@ -332,7 +332,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "O"
self.assertEqual(result, 'O', 'The result should be "O", but was "%s"' % result)
def translated_name_test(self):
def test_translated_name(self):
"""
Test that the translated_name() method returns the correct name
"""
@ -352,7 +352,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "Chorus"
self.assertEqual(result, 'Chorus', 'The result should be "Chorus"')
def translated_invalid_name_test(self):
def test_translated_invalid_name(self):
"""
Test that the translated_name() method returns the default name when passed an invalid tag
"""
@ -366,7 +366,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "Other"
self.assertEqual(result, 'Other', 'The result should be "Other", but was "%s"' % result)
def translated_invalid_name_with_specified_default_test(self):
def test_translated_invalid_name_with_specified_default(self):
"""
Test that the translated_name() method returns the specified default name when passed an invalid tag
"""
@ -380,7 +380,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "Bridge"
self.assertEqual(result, 'Bridge', 'The result should be "Bridge", but was "%s"' % result)
def translated_invalid_name_with_invalid_default_test(self):
def test_translated_invalid_name_with_invalid_default(self):
"""
Test that the translated_name() method returns the specified default tag when passed an invalid tag
"""
@ -394,7 +394,7 @@ class TestVerseType(TestCase):
# THEN: The result should be "Other"
self.assertEqual(result, 'Other', 'The result should be "Other", but was "%s"' % result)
def from_tag_test(self):
def test_from_tag(self):
"""
Test that the from_tag() method returns the correct VerseType.
"""
@ -408,7 +408,7 @@ class TestVerseType(TestCase):
# THEN: The result should be VerseType.Verse
self.assertEqual(result, VerseType.Verse, 'The result should be VerseType.Verse, but was "%s"' % result)
def from_tag_with_invalid_tag_test(self):
def test_from_tag_with_invalid_tag(self):
"""
Test that the from_tag() method returns the default VerseType when it is passed an invalid tag.
"""
@ -422,7 +422,7 @@ class TestVerseType(TestCase):
# THEN: The result should be VerseType.Other
self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
def from_tag_with_specified_default_test(self):
def test_from_tag_with_specified_default(self):
"""
Test that the from_tag() method returns the specified default when passed an invalid tag.
"""
@ -436,7 +436,7 @@ class TestVerseType(TestCase):
# THEN: The result should be VerseType.Chorus
self.assertEqual(result, VerseType.Chorus, 'The result should be VerseType.Chorus, but was "%s"' % result)
def from_tag_with_invalid_intdefault_test(self):
def test_from_tag_with_invalid_intdefault(self):
"""
Test that the from_tag() method returns a sane default when passed an invalid tag and an invalid int default.
"""
@ -450,7 +450,7 @@ class TestVerseType(TestCase):
# THEN: The result should be VerseType.Other
self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
def from_tag_with_invalid_default_test(self):
def test_from_tag_with_invalid_default(self):
"""
Test that the from_tag() method returns a sane default when passed an invalid tag and an invalid default.
"""
@ -464,7 +464,7 @@ class TestVerseType(TestCase):
# THEN: The result should be VerseType.Other
self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
def from_tag_with_none_default_test(self):
def test_from_tag_with_none_default(self):
"""
Test that the from_tag() method returns a sane default when passed an invalid tag and None as default.
"""
@ -479,7 +479,7 @@ class TestVerseType(TestCase):
self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
def from_loose_input_with_invalid_input_test(self, mocked_translated_tags):
def test_from_loose_input_with_invalid_input(self, mocked_translated_tags):
"""
Test that the from_loose_input() method returns a sane default when passed an invalid tag and None as default.
"""
@ -491,7 +491,7 @@ class TestVerseType(TestCase):
self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
def from_loose_input_with_valid_input_test(self, mocked_translated_tags):
def test_from_loose_input_with_valid_input(self, mocked_translated_tags):
"""
Test that the from_loose_input() method returns valid output on valid input.
"""

View File

@ -68,7 +68,7 @@ class TestMediaItem(TestCase, TestMixin):
"""
self.destroy_settings()
def display_results_song_test(self):
def test_display_results_song(self):
"""
Test displaying song search results with basic song
"""
@ -109,7 +109,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
self.media_item.list_view.setCurrentItem.assert_called_with(mock_qlist_widget)
def display_results_author_test(self):
def test_display_results_author(self):
"""
Test displaying song search results grouped by author with basic song
"""
@ -145,7 +145,7 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def display_results_book_test(self):
def test_display_results_book(self):
"""
Test displaying song search results grouped by book and entry with basic song
"""
@ -165,7 +165,7 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, 1)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def songbook_natural_sorting_test(self):
def test_songbook_natural_sorting(self):
"""
Test that songbooks are sorted naturally
"""
@ -191,7 +191,7 @@ class TestMediaItem(TestCase, TestMixin):
call('Thy Book #2: Thy Song'), call().setData(QtCore.Qt.UserRole, 50)]
MockedQListWidgetItem.assert_has_calls(calls)
def display_results_topic_test(self):
def test_display_results_topic(self):
"""
Test displaying song search results grouped by topic with basic song
"""
@ -227,7 +227,7 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def display_results_themes_test(self):
def test_display_results_themes(self):
"""
Test displaying song search results sorted by theme with basic song
"""
@ -261,7 +261,7 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def display_results_cclinumber_test(self):
def test_display_results_cclinumber(self):
"""
Test displaying song search results sorted by CCLI number with basic song
"""
@ -295,7 +295,7 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def build_song_footer_one_author_test(self):
def test_build_song_footer_one_author(self):
"""
Test build songs footer with basic song and one author
"""
@ -320,7 +320,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')
def build_song_footer_two_authors_test(self):
def test_build_song_footer_two_authors(self):
"""
Test build songs footer with basic song and two authors
"""
@ -359,7 +359,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(author_list, ['another author', 'my author', 'translator'],
'The author list should be returned correctly with two authors')
def build_song_footer_base_ccli_test(self):
def test_build_song_footer_base_ccli(self):
"""
Test build songs footer with basic song and a CCLI number
"""
@ -385,7 +385,7 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'],
'The array should be returned correctly with a song, an author, copyright and amended ccli')
def build_song_footer_base_songbook_test(self):
def test_build_song_footer_base_songbook(self):
"""
Test build songs footer with basic song and multiple songbooks
"""
@ -418,7 +418,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: The songbook should be in the footer
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'My songbook #12, Thy songbook #502A'])
def build_song_footer_copyright_enabled_test(self):
def test_build_song_footer_copyright_enabled(self):
"""
Test building song footer with displaying the copyright symbol
"""
@ -435,7 +435,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: The copyright symbol should be in the footer
self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright'])
def build_song_footer_copyright_disabled_test(self):
def test_build_song_footer_copyright_disabled(self):
"""
Test building song footer without displaying the copyright symbol
"""
@ -451,7 +451,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: The copyright symbol should not be in the footer
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
def authors_match_test(self):
def test_authors_match(self):
"""
Test the author matching when importing a song from a service
"""
@ -477,7 +477,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: They should match
self.assertTrue(result, "Authors should match")
def authors_dont_match_test(self):
def test_authors_dont_match(self):
# GIVEN: A song and a string with authors
song = MagicMock()
song.authors = []
@ -500,7 +500,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: They should not match
self.assertFalse(result, "Authors should not match")
def build_remote_search_test(self):
def test_build_remote_search(self):
"""
Test results for the remote search api
"""

View File

@ -39,7 +39,7 @@ class TestOpenLPImport(TestCase):
"""
Registry.create()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the OpenLP database importer
"""
@ -53,7 +53,7 @@ class TestOpenLPImport(TestCase):
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
def invalid_import_source_test(self):
def test_invalid_import_source(self):
"""
Test OpenLPSongImport.do_import handles different invalid import_source values
"""

View File

@ -51,7 +51,7 @@ class TestOpenLyricsExport(TestCase, TestMixin):
"""
shutil.rmtree(self.temp_folder)
def export_same_filename_test(self):
def test_export_same_filename(self):
"""
Test that files is not overwritten if songs has same title and author
"""

View File

@ -100,7 +100,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
"""
self.destroy_settings()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the OpenLyrics file importer
"""
@ -114,7 +114,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
# THEN: The importer should be an instance of SongImport
self.assertIsInstance(importer, SongImport)
def file_import_test(self):
def test_file_import(self):
"""
Test the actual import of real song files
"""
@ -134,7 +134,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
# THEN: The xml_to_song() method should have been called
self.assertTrue(importer.open_lyrics.xml_to_song.called)
def process_formatting_tags_test(self):
def test_process_formatting_tags(self):
"""
Test that _process_formatting_tags works
"""
@ -155,7 +155,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
json.loads(str(Settings().value('formattingTags/html_tags'))),
'The formatting tags should contain both the old and the new')
def process_author_test(self):
def test_process_author(self):
"""
Test that _process_authors works
"""
@ -174,7 +174,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
self.assertEquals(mocked_song.method_calls[0][1][1], 'words+music')
self.assertEquals(mocked_song.method_calls[1][1][1], 'words')
def process_songbooks_test(self):
def test_process_songbooks(self):
"""
Test that _process_songbooks works
"""

View File

@ -46,7 +46,7 @@ class TestOpenOfficeImport(TestCase, TestMixin):
Registry.create()
@patch('openlp.plugins.songs.lib.importers.openoffice.SongImport')
def create_importer_test(self, mocked_songimport):
def test_create_importer(self, mocked_songimport):
"""
Test creating an instance of the OpenOfficeImport file importer
"""
@ -60,7 +60,7 @@ class TestOpenOfficeImport(TestCase, TestMixin):
self.assertIsNotNone(importer, 'Import should not be none')
@patch('openlp.plugins.songs.lib.importers.openoffice.SongImport')
def close_ooo_file_test(self, mocked_songimport):
def test_close_ooo_file(self, mocked_songimport):
"""
Test that close_ooo_file catches raised exceptions
"""

View File

@ -66,7 +66,7 @@ class TestOpenSongImport(TestCase):
"""
Registry.create()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the OpenSong file importer
"""
@ -80,7 +80,7 @@ class TestOpenSongImport(TestCase):
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
def invalid_import_source_test(self):
def test_invalid_import_source(self):
"""
Test OpenSongImport.do_import handles different invalid import_source values
"""
@ -101,7 +101,7 @@ class TestOpenSongImport(TestCase):
self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
'setMaximum on import_wizard.progress_bar should not have been called')
def valid_import_source_test(self):
def test_valid_import_source(self):
"""
Test OpenSongImport.do_import handles different invalid import_source values
"""

View File

@ -24,19 +24,21 @@ This module contains tests for the WorshipCenter Pro song importer.
"""
import os
import json
from unittest import TestCase, SkipTest
from unittest import TestCase, skipUnless
if os.name != 'nt':
raise SkipTest('Not Windows, skipping test')
try:
from openlp.core.common import Registry
from openlp.plugins.songs.lib.importers.opspro import OPSProImport
CAN_RUN_TESTS = True
except ImportError:
CAN_RUN_TESTS = False
from tests.functional import patch, MagicMock
from openlp.core.common import Registry
from openlp.plugins.songs.lib.importers.opspro import OPSProImport
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opsprosongs'))
@skipUnless(CAN_RUN_TESTS, 'Not Windows, skipping test')
class TestOpsProSongImport(TestCase):
"""
Test the functions in the :mod:`opsproimport` module.
@ -48,7 +50,7 @@ class TestOpsProSongImport(TestCase):
Registry.create()
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def create_importer_test(self, mocked_songimport):
def test_create_importer(self, mocked_songimport):
"""
Test creating an instance of the OPS Pro file importer
"""
@ -62,7 +64,7 @@ class TestOpsProSongImport(TestCase):
self.assertIsNotNone(importer, 'Import should not be none')
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def detect_chorus_test(self, mocked_songimport):
def test_detect_chorus(self, mocked_songimport):
"""
Test importing lyrics with a chorus in OPS Pro
"""
@ -82,7 +84,7 @@ class TestOpsProSongImport(TestCase):
self.assertListEqual(importer.verse_order_list_generated, self._get_data(result_data, 'verse_order_list'))
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def join_and_split_test(self, mocked_songimport):
def test_join_and_split(self, mocked_songimport):
"""
Test importing lyrics with a split and join tags works in OPS Pro
"""
@ -102,7 +104,7 @@ class TestOpsProSongImport(TestCase):
self.assertListEqual(importer.verse_order_list_generated, self._get_data(result_data, 'verse_order_list'))
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def trans_off_tag_test(self, mocked_songimport):
def test_trans_off_tag(self, mocked_songimport):
"""
Test importing lyrics with a split and join and translations tags works in OPS Pro
"""
@ -122,7 +124,7 @@ class TestOpsProSongImport(TestCase):
self.assertListEqual(importer.verse_order_list_generated, self._get_data(result_data, 'verse_order_list'))
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def trans_tag_test(self, mocked_songimport):
def test_trans_tag(self, mocked_songimport):
"""
Test importing lyrics with various translations tags works in OPS Pro
"""

View File

@ -60,7 +60,7 @@ class TestSongBeamerImport(TestCase):
"""
Registry.create()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the SongBeamer file importer
"""
@ -74,7 +74,7 @@ class TestSongBeamerImport(TestCase):
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
def invalid_import_source_test(self):
def test_invalid_import_source(self):
"""
Test SongBeamerImport.do_import handles different invalid import_source values
"""
@ -95,7 +95,7 @@ class TestSongBeamerImport(TestCase):
self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
'setMaxium on import_wizard.progress_bar should not have been called')
def valid_import_source_test(self):
def test_valid_import_source(self):
"""
Test SongBeamerImport.do_import handles different invalid import_source values
"""
@ -116,7 +116,7 @@ class TestSongBeamerImport(TestCase):
'do_import should return None when import_source is a list and stop_import_flag is True')
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
def check_verse_marks_test(self):
def test_check_verse_marks(self):
"""
Tests different lines to see if a verse mark is detected or not
"""

View File

@ -47,7 +47,7 @@ class TestSongSelectImport(TestCase, TestMixin):
Test the :class:`~openlp.plugins.songs.lib.songselect.SongSelectImport` class
"""
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def constructor_test(self, mocked_build_opener):
def test_constructor(self, mocked_build_opener):
"""
Test that constructing a basic SongSelectImport object works correctly
"""
@ -63,7 +63,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def login_fails_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_login_fails(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that when logging in to SongSelect fails, the login method returns False
"""
@ -86,7 +86,7 @@ class TestSongSelectImport(TestCase, TestMixin):
self.assertFalse(result, 'The login method should have returned False')
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def login_except_test(self, mocked_build_opener):
def test_login_except(self, mocked_build_opener):
"""
Test that when logging in to SongSelect fails, the login method raises URLError
"""
@ -104,7 +104,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def login_succeeds_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_login_succeeds(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that when logging in to SongSelect succeeds, the login method returns True
"""
@ -127,7 +127,7 @@ class TestSongSelectImport(TestCase, TestMixin):
self.assertTrue(result, 'The login method should have returned True')
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def logout_test(self, mocked_build_opener):
def test_logout(self, mocked_build_opener):
"""
Test that when the logout method is called, it logs the user out of SongSelect
"""
@ -145,7 +145,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def search_returns_no_results_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_search_returns_no_results(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that when the search finds no results, it simply returns an empty list
"""
@ -170,7 +170,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def search_returns_two_results_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_search_returns_two_results(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that when the search finds 2 results, it simply returns a list with 2 results
"""
@ -208,7 +208,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def search_reaches_max_results_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_search_reaches_max_results(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that when the search finds MAX (2) results, it simply returns a list with those (2)
"""
@ -248,7 +248,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def stop_called_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_stop_called(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that the search is stopped with stop() is called
"""
@ -263,7 +263,7 @@ class TestSongSelectImport(TestCase, TestMixin):
self.assertFalse(importer.run_search, 'Searching should have been stopped')
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def get_song_page_raises_exception_test(self, mocked_build_opener):
def test_get_song_page_raises_exception(self, mocked_build_opener):
"""
Test that when BeautifulSoup gets a bad song page the get_song() method returns None
"""
@ -283,7 +283,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def get_song_lyrics_raise_exception_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_get_song_lyrics_raise_exception(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that when BeautifulSoup gets a bad lyrics page the get_song() method returns None
"""
@ -301,7 +301,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
def get_song_test(self, MockedBeautifulSoup, mocked_build_opener):
def test_get_song(self, MockedBeautifulSoup, mocked_build_opener):
"""
Test that the get_song() method returns the correct song details
"""
@ -349,7 +349,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.clean_song')
@patch('openlp.plugins.songs.lib.songselect.Author')
def save_song_new_author_test(self, MockedAuthor, mocked_clean_song):
def test_save_song_new_author(self, MockedAuthor, mocked_clean_song):
"""
Test that saving a song with a new author performs the correct actions
"""
@ -385,7 +385,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.clean_song')
@patch('openlp.plugins.songs.lib.songselect.Author')
def save_song_existing_author_test(self, MockedAuthor, mocked_clean_song):
def test_save_song_existing_author(self, MockedAuthor, mocked_clean_song):
"""
Test that saving a song with an existing author performs the correct actions
"""
@ -420,7 +420,7 @@ class TestSongSelectImport(TestCase, TestMixin):
@patch('openlp.plugins.songs.lib.songselect.clean_song')
@patch('openlp.plugins.songs.lib.songselect.Author')
def save_song_unknown_author_test(self, MockedAuthor, mocked_clean_song):
def test_save_song_unknown_author(self, MockedAuthor, mocked_clean_song):
"""
Test that saving a song with an author name of only one word performs the correct actions
"""
@ -469,7 +469,7 @@ class TestSongSelectForm(TestCase, TestMixin):
Registry.create()
Registry().register('application', self.app)
def create_form_test(self):
def test_create_form(self):
"""
Test that we can create the SongSelect form
"""
@ -487,7 +487,7 @@ class TestSongSelectForm(TestCase, TestMixin):
@patch('openlp.plugins.songs.forms.songselectform.SongSelectImport')
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.critical')
@patch('openlp.plugins.songs.forms.songselectform.translate')
def login_fails_test(self, mocked_translate, mocked_critical, MockedSongSelectImport):
def test_login_fails(self, mocked_translate, mocked_critical, MockedSongSelectImport):
"""
Test that when the login fails, the form returns to the correct state
"""
@ -540,7 +540,7 @@ class TestSongSelectForm(TestCase, TestMixin):
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.question')
@patch('openlp.plugins.songs.forms.songselectform.translate')
def on_import_yes_clicked_test(self, mocked_translate, mocked_question):
def test_on_import_yes_clicked(self, mocked_translate, mocked_question):
"""
Test that when a song is imported and the user clicks the "yes" button, the UI goes back to the previous page
"""
@ -567,7 +567,7 @@ class TestSongSelectForm(TestCase, TestMixin):
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.question')
@patch('openlp.plugins.songs.forms.songselectform.translate')
def on_import_no_clicked_test(self, mocked_translate, mocked_question):
def test_on_import_no_clicked(self, mocked_translate, mocked_question):
"""
Test that when a song is imported and the user clicks the "no" button, the UI exits
"""
@ -592,7 +592,7 @@ class TestSongSelectForm(TestCase, TestMixin):
mocked_done.assert_called_with(QtWidgets.QDialog.Accepted)
self.assertIsNone(ssform.song)
def on_back_button_clicked_test(self):
def test_on_back_button_clicked(self):
"""
Test that when the back button is clicked, the stacked widget is set back one page
"""
@ -609,7 +609,7 @@ class TestSongSelectForm(TestCase, TestMixin):
mocked_search_combobox.setFocus.assert_called_with()
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.information')
def on_search_show_info_test(self, mocked_information):
def test_on_search_show_info(self, mocked_information):
"""
Test that when the search_show_info signal is emitted, the on_search_show_info() method shows a dialog
"""
@ -624,7 +624,7 @@ class TestSongSelectForm(TestCase, TestMixin):
# THEN: An information dialog should be shown
mocked_information.assert_called_with(ssform, expected_title, expected_text)
def update_login_progress_test(self):
def test_update_login_progress(self):
"""
Test the _update_login_progress() method
"""
@ -639,7 +639,7 @@ class TestSongSelectForm(TestCase, TestMixin):
# THEN: The login progress bar should be updated
mocked_login_progress_bar.setValue.assert_called_with(4)
def update_song_progress_test(self):
def test_update_song_progress(self):
"""
Test the _update_song_progress() method
"""
@ -654,7 +654,7 @@ class TestSongSelectForm(TestCase, TestMixin):
# THEN: The song progress bar should be updated
mocked_song_progress_bar.setValue.assert_called_with(3)
def on_search_results_widget_double_clicked_test(self):
def test_on_search_results_widget_double_clicked(self):
"""
Test that a song is retrieved when a song in the results list is double-clicked
"""
@ -669,7 +669,7 @@ class TestSongSelectForm(TestCase, TestMixin):
# THEN: The song is fetched and shown to the user
mocked_view_song.assert_called_with(expected_song)
def on_view_button_clicked_test(self):
def test_on_view_button_clicked(self):
"""
Test that a song is retrieved when the view button is clicked
"""
@ -686,7 +686,7 @@ class TestSongSelectForm(TestCase, TestMixin):
# THEN: The song is fetched and shown to the user
mocked_view_song.assert_called_with(expected_song)
def on_search_results_widget_selection_changed_test(self):
def test_on_search_results_widget_selection_changed(self):
"""
Test that the view button is updated when the search results list is changed
"""
@ -703,7 +703,7 @@ class TestSongSelectForm(TestCase, TestMixin):
mocked_view_button.setEnabled.assert_called_with(True)
@patch('openlp.plugins.songs.forms.songselectform.SongSelectImport')
def on_stop_button_clicked_test(self, MockedSongSelectImport):
def test_on_stop_button_clicked(self, MockedSongSelectImport):
"""
Test that the search is stopped when the stop button is clicked
"""
@ -724,7 +724,7 @@ class TestSongSelectForm(TestCase, TestMixin):
@patch('openlp.plugins.songs.forms.songselectform.Settings')
@patch('openlp.plugins.songs.forms.songselectform.QtCore.QThread')
@patch('openlp.plugins.songs.forms.songselectform.SearchWorker')
def on_search_button_clicked_test(self, MockedSearchWorker, MockedQtThread, MockedSettings):
def test_on_search_button_clicked(self, MockedSearchWorker, MockedQtThread, MockedSettings):
"""
Test that search fields are disabled when search button is clicked.
"""
@ -739,7 +739,7 @@ class TestSongSelectForm(TestCase, TestMixin):
self.assertFalse(ssform.search_button.isEnabled())
self.assertFalse(ssform.search_combobox.isEnabled())
def on_search_finished_test(self):
def test_on_search_finished(self):
"""
Test that search fields are enabled when search is finished.
"""
@ -776,7 +776,7 @@ class TestSearchWorker(TestCase, TestMixin):
"""
Test the SearchWorker class
"""
def constructor_test(self):
def test_constructor(self):
"""
Test the SearchWorker constructor
"""
@ -791,7 +791,7 @@ class TestSearchWorker(TestCase, TestMixin):
self.assertIs(importer, worker.importer, 'The importer should be the right object')
self.assertEqual(search_text, worker.search_text, 'The search text should be correct')
def start_test(self):
def test_start(self):
"""
Test the start() method of the SearchWorker class
"""
@ -811,7 +811,7 @@ class TestSearchWorker(TestCase, TestMixin):
mocked_quit.emit.assert_called_with()
@patch('openlp.plugins.songs.forms.songselectform.translate')
def start_over_1000_songs_test(self, mocked_translate):
def test_start_over_1000_songs(self, mocked_translate):
"""
Test the start() method of the SearchWorker class when it finds over 1000 songs
"""
@ -836,7 +836,7 @@ class TestSearchWorker(TestCase, TestMixin):
mocked_finished.emit.assert_called_with()
mocked_quit.emit.assert_called_with()
def found_song_callback_test(self):
def test_found_song_callback(self):
"""
Test that when the _found_song_callback() function is called, the "found_song" signal is emitted
"""

View File

@ -58,7 +58,7 @@ class TestSongShowPlusImport(TestCase):
"""
Test the functions in the :mod:`songshowplusimport` module.
"""
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the SongShow Plus file importer
"""
@ -72,7 +72,7 @@ class TestSongShowPlusImport(TestCase):
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
def invalid_import_source_test(self):
def test_invalid_import_source(self):
"""
Test SongShowPlusImport.do_import handles different invalid import_source values
"""
@ -93,7 +93,7 @@ class TestSongShowPlusImport(TestCase):
self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
'setMaximum on import_wizard.progress_bar should not have been called')
def valid_import_source_test(self):
def test_valid_import_source(self):
"""
Test SongShowPlusImport.do_import handles different invalid import_source values
"""
@ -114,7 +114,7 @@ class TestSongShowPlusImport(TestCase):
'and stop_import_flag is True')
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
def to_openlp_verse_tag_test(self):
def test_to_openlp_verse_tag(self):
"""
Test to_openlp_verse_tag method by simulating adding a verse
"""
@ -142,7 +142,7 @@ class TestSongShowPlusImport(TestCase):
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
(openlp_tag, original_tag))
def to_openlp_verse_tag_verse_order_test(self):
def test_to_openlp_verse_tag_verse_order(self):
"""
Test to_openlp_verse_tag method by simulating adding a verse to the verse order
"""

View File

@ -22,48 +22,50 @@
"""
This module contains tests for the WorshipCenter Pro song importer.
"""
import os
from unittest import TestCase, SkipTest
from unittest import TestCase, skipUnless
try:
import pyodbc
from openlp.core.common import Registry
from openlp.plugins.songs.lib.importers.worshipcenterpro import WorshipCenterProImport
CAN_RUN_TESTS = True
except ImportError:
CAN_RUN_TESTS = False
if os.name != 'nt':
raise SkipTest('Not Windows, skipping test')
import pyodbc
from tests.functional import patch, MagicMock
from openlp.core.common import Registry
from openlp.plugins.songs.lib.importers.worshipcenterpro import WorshipCenterProImport
class TestRecord(object):
"""
Microsoft Access Driver is not available on non Microsoft Systems for this reason the :class:`TestRecord` is used
to simulate a recordset that would be returned by pyobdc.
"""
def __init__(self, id, field, value):
def __init__(self, id_, field, value):
# The case of the following instance variables is important as it needs to be the same as the ones in use in the
# WorshipCenter Pro database.
self.ID = id
self.ID = id_
self.Field = field
self.Value = value
class WorshipCenterProImportLogger(WorshipCenterProImport):
"""
This class logs changes in the title instance variable
"""
_title_assignment_list = []
if CAN_RUN_TESTS:
class WorshipCenterProImportLogger(WorshipCenterProImport):
"""
This class logs changes in the title instance variable
"""
_title_assignment_list = []
def __init__(self, manager):
WorshipCenterProImport.__init__(self, manager, filenames=[])
def __init__(self, manager):
WorshipCenterProImport.__init__(self, manager, filenames=[])
@property
def title(self):
return self._title_assignment_list[-1]
@property
def title(self):
return self._title_assignment_list[-1]
@title.setter
def title(self, title):
self._title_assignment_list.append(title)
@title.setter
def title(self, title):
self._title_assignment_list.append(title)
RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
@ -133,6 +135,7 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace',
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
@skipUnless(CAN_RUN_TESTS, 'Not Windows, skipping test')
class TestWorshipCenterProSongImport(TestCase):
"""
Test the functions in the :mod:`worshipcenterproimport` module.
@ -143,7 +146,7 @@ class TestWorshipCenterProSongImport(TestCase):
"""
Registry.create()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the WorshipCenter Pro file importer
"""
@ -157,7 +160,7 @@ class TestWorshipCenterProSongImport(TestCase):
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
def pyodbc_exception_test(self):
def test_pyodbc_exception(self):
"""
Test that exceptions raised by pyodbc are handled
"""
@ -186,7 +189,7 @@ class TestWorshipCenterProSongImport(TestCase):
'Unable to connect the WorshipCenter Pro database.')
mocked_log_error.assert_called_with('import_source', 'Translated Text')
def song_import_test(self):
def test_song_import(self):
"""
Test that a simulated WorshipCenter Pro recordset is imported correctly
"""

View File

@ -46,7 +46,7 @@ class TestZionWorxImport(TestCase):
"""
Registry.create()
def create_importer_test(self):
def test_create_importer(self):
"""
Test creating an instance of the ZionWorx file importer
"""

View File

@ -36,7 +36,7 @@ class TestSongUsage(TestCase):
def setUp(self):
Registry.create()
def about_text_test(self):
def test_about_text(self):
"""
Test the about text of the song usage plugin
"""
@ -49,7 +49,7 @@ class TestSongUsage(TestCase):
self.assertNotEquals(len(SongUsagePlugin.about()), 0)
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def song_usage_init_test(self, MockedManager):
def test_song_usage_init(self, MockedManager):
"""
Test the initialisation of the SongUsagePlugin class
"""
@ -66,7 +66,7 @@ class TestSongUsage(TestCase):
self.assertFalse(song_usage.song_usage_active)
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def check_pre_conditions_test(self, MockedManager):
def test_check_pre_conditions(self, MockedManager):
"""
Test that check_pre_condition returns true for valid manager session
"""
@ -83,7 +83,7 @@ class TestSongUsage(TestCase):
self.assertTrue(ret)
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def toggle_song_usage_state_test(self, MockedManager):
def test_toggle_song_usage_state(self, MockedManager):
"""
Test that toggle_song_usage_state does toggle song_usage_state
"""

View File

@ -47,7 +47,7 @@ class TestInit(TestCase, TestMixin):
self.destroy_settings()
del self.openlp
def event_test(self):
def test_event(self):
"""
Test the reimplemented event method
"""
@ -66,7 +66,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(self.openlp.args[0], file_path, "The path should be in args.")
@patch('openlp.core.is_macosx')
def application_activate_event_test(self, mocked_is_macosx):
def test_application_activate_event(self, mocked_is_macosx):
"""
Test that clicking on the dock icon on Mac OS X restores the main window if it is minimized
"""
@ -84,7 +84,7 @@ class TestInit(TestCase, TestMixin):
self.assertTrue(result, "The method should have returned True.")
# self.assertFalse(self.openlp.main_window.isMinimized())
def backup_on_upgrade_first_install_test(self):
def test_backup_on_upgrade_first_install(self):
"""
Test that we don't try to backup on a new install
"""
@ -108,7 +108,7 @@ class TestInit(TestCase, TestMixin):
self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be the same!')
self.assertEqual(mocked_question.call_count, 0, 'No question should have been asked!')
def backup_on_upgrade_test(self):
def test_backup_on_upgrade(self):
"""
Test that we try to backup on a new install
"""

View File

@ -41,7 +41,7 @@ class TestUtils(TestCase, TestMixin):
"""
self.setup_application()
def is_not_image_empty_test(self):
def test_is_not_image_empty(self):
"""
Test the method handles an empty string
"""
@ -54,7 +54,7 @@ class TestUtils(TestCase, TestMixin):
# THEN the result is false
assert result is True, 'The missing file test should return True'
def is_not_image_with_image_file_test(self):
def test_is_not_image_with_image_file(self):
"""
Test the method handles an image file
"""
@ -67,7 +67,7 @@ class TestUtils(TestCase, TestMixin):
# THEN the result is false
assert result is False, 'The file is present so the test should return False'
def is_not_image_with_none_image_file_test(self):
def test_is_not_image_with_none_image_file(self):
"""
Test the method handles a non image file
"""

View File

@ -69,7 +69,7 @@ class TestPluginManager(TestCase, TestMixin):
@patch('openlp.plugins.custom.lib.db.init_schema')
@patch('openlp.plugins.alerts.lib.db.init_schema')
@patch('openlp.plugins.bibles.lib.db.init_schema')
def find_plugins_test(self, mocked_is1, mocked_is2, mocked_is3, mocked_is4, mocked_is5, mocked_is6):
def test_find_plugins(self, mocked_is1, mocked_is2, mocked_is3, mocked_is4, mocked_is5, mocked_is6):
"""
Test the find_plugins() method to ensure it imports the correct plugins
"""

View File

@ -69,7 +69,7 @@ class TestSearchEdit(TestCase, TestMixin):
del self.search_edit
del self.main_window
def set_search_types_test(self):
def test_set_search_types(self):
"""
Test setting the search types of the search edit.
"""
@ -81,7 +81,7 @@ class TestSearchEdit(TestCase, TestMixin):
# THEN: The first search type should be the first one in the list.
assert self.search_edit.current_search_type() == SearchTypes.First, "The first search type should be selected."
def set_current_search_type_test(self):
def test_set_current_search_type(self):
"""
Test if changing the search type works.
"""
@ -96,7 +96,7 @@ class TestSearchEdit(TestCase, TestMixin):
assert self.search_edit.placeholderText() == SECOND_PLACEHOLDER_TEXT,\
"The correct placeholder text should be 'Second Placeholder Text'."
def clear_button_visibility_test(self):
def test_clear_button_visibility(self):
"""
Test if the clear button is hidden/shown correctly.
"""
@ -110,7 +110,7 @@ class TestSearchEdit(TestCase, TestMixin):
# THEN: The clear button should not be hidden any more.
assert not self.search_edit.clear_button.isHidden(), "The clear button should be visible."
def press_clear_button_test(self):
def test_press_clear_button(self):
"""
Check if the search edit behaves correctly when pressing the clear button.
"""

View File

@ -51,7 +51,7 @@ class TestStartFileRenameForm(TestCase, TestMixin):
del self.form
del self.main_window
def window_title_test(self):
def test_window_title(self):
"""
Test the windowTitle of the FileRenameDialog
"""
@ -76,7 +76,7 @@ class TestStartFileRenameForm(TestCase, TestMixin):
# THEN: the window title is set correctly
self.assertEqual(self.form.windowTitle(), 'File Copy', 'The window title should be "File Copy"')
def line_edit_focus_test(self):
def test_line_edit_focus(self):
"""
Regression test for bug1067251
Test that the file_name_edit setFocus has called with True when executed
@ -92,7 +92,7 @@ class TestStartFileRenameForm(TestCase, TestMixin):
# THEN: the setFocus method of the file_name_edit has been called with True
mocked_set_focus.assert_called_with()
def file_name_validation_test(self):
def test_file_name_validation(self):
"""
Test the file_name_edit validation
"""

View File

@ -65,7 +65,7 @@ class TestMainWindow(TestCase, TestMixin):
"""
del self.main_window
def restore_current_media_manager_item_test(self):
def test_restore_current_media_manager_item(self):
"""
Regression test for bug #1152509.
"""
@ -80,7 +80,7 @@ class TestMainWindow(TestCase, TestMixin):
# THEN: The current widget should have been set.
self.main_window.media_tool_box.setCurrentIndex.assert_called_with(2)
def projector_manager_dock_locked_test(self):
def test_projector_manager_dock_locked(self):
"""
Projector Manager enable UI options - bug #1390702
"""
@ -93,7 +93,7 @@ class TestMainWindow(TestCase, TestMixin):
# THEN: Projector manager dock should have been called with disable UI features
projector_dock.setFeatures.assert_called_with(0)
def projector_manager_dock_unlocked_test(self):
def test_projector_manager_dock_unlocked(self):
"""
Projector Manager disable UI options - bug #1390702
"""

View File

@ -66,7 +66,7 @@ class TestProjectorEditForm(TestCase, TestMixin):
del(self.projector_form)
self.destroy_settings()
def edit_form_add_projector_test(self):
def test_edit_form_add_projector(self):
"""
Test projector edit form with no parameters creates a new entry.
@ -85,7 +85,7 @@ class TestProjectorEditForm(TestCase, TestMixin):
self.assertTrue((item.ip is None and item.name is None),
'Projector edit form should have a new Projector() instance to edit')
def edit_form_edit_projector_test(self):
def test_edit_form_edit_projector(self):
"""
Test projector edit form with existing projector entry

View File

@ -63,7 +63,7 @@ class TestProjectorManager(TestCase, TestMixin):
self.destroy_settings()
del self.projector_manager
def bootstrap_initialise_test(self):
def test_bootstrap_initialise(self):
"""
Test initialize calls correct startup functions
"""
@ -73,7 +73,7 @@ class TestProjectorManager(TestCase, TestMixin):
self.assertEqual(type(self.projector_manager.projectordb), ProjectorDB,
'Initialization should have created a ProjectorDB() instance')
def bootstrap_post_set_up_test(self):
def test_bootstrap_post_set_up(self):
"""
Test post-initialize calls proper setups
"""

View File

@ -100,7 +100,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
retries += 1
self.destroy_settings()
def source_dict_test(self):
def test_source_dict(self):
"""
Test that source list dict returned from sourceselectform module is a valid dict with proper entries
"""
@ -118,7 +118,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
"Source group dictionary should match test dictionary")
@patch.object(QDialog, 'exec')
def source_select_edit_button_test(self, mocked_qdialog):
def test_source_select_edit_button(self, mocked_qdialog):
"""
Test source select form edit has Ok, Cancel, Reset, and Revert buttons
"""
@ -138,7 +138,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
'"Rest", and "Revert" buttons available')
@patch.object(QDialog, 'exec')
def source_select_noedit_button_test(self, mocked_qdialog):
def test_source_select_noedit_button(self, mocked_qdialog):
"""
Test source select form view has OK and Cancel buttons only
"""

View File

@ -62,7 +62,7 @@ class TestServiceManager(TestCase, TestMixin):
"""
del self.main_window
def basic_service_manager_test(self):
def test_basic_service_manager(self):
"""
Test the Service Manager UI Functionality
"""
@ -74,7 +74,7 @@ class TestServiceManager(TestCase, TestMixin):
self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0,
'The service manager list should be empty ')
def default_context_menu_test(self):
def test_default_context_menu(self):
"""
Test the context_menu() method with a default service item
"""
@ -116,7 +116,7 @@ class TestServiceManager(TestCase, TestMixin):
self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \
'The action should be set invisible.'
def edit_context_menu_test(self):
def test_edit_context_menu(self):
"""
Test the context_menu() method with a edit service item
"""
@ -160,7 +160,7 @@ class TestServiceManager(TestCase, TestMixin):
self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \
'The action should be set invisible.'
def maintain_context_menu_test(self):
def test_maintain_context_menu(self):
"""
Test the context_menu() method with a maintain
"""
@ -203,7 +203,7 @@ class TestServiceManager(TestCase, TestMixin):
self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \
'The action should be set invisible.'
def loopy_context_menu_test(self):
def test_loopy_context_menu(self):
"""
Test the context_menu() method with a loop
"""
@ -248,7 +248,7 @@ class TestServiceManager(TestCase, TestMixin):
self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \
'The action should be set invisible.'
def start_time_context_menu_test(self):
def test_start_time_context_menu(self):
"""
Test the context_menu() method with a start time
"""
@ -291,7 +291,7 @@ class TestServiceManager(TestCase, TestMixin):
self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \
'The action should be set invisible.'
def auto_start_context_menu_test(self):
def test_auto_start_context_menu(self):
"""
Test the context_menu() method with can auto start
"""
@ -337,7 +337,7 @@ class TestServiceManager(TestCase, TestMixin):
self.service_manager.rename_action.setVisible.assert_called_once_with(False), \
'The action should be set invisible.'
def click_on_new_service_test(self):
def test_click_on_new_service(self):
"""
Test the on_new_service event handler is called by the UI
"""

View File

@ -51,7 +51,7 @@ class TestStartNoteDialog(TestCase, TestMixin):
del self.form
del self.main_window
def basic_display_test(self):
def test_basic_display(self):
"""
Test Service Note form functionality
"""

View File

@ -66,7 +66,7 @@ class TestSettingsForm(TestCase, TestMixin):
"""
del self.form
def basic_cancel_test(self):
def test_basic_cancel(self):
"""
Test running the settings form and pressing Cancel
"""
@ -80,7 +80,7 @@ class TestSettingsForm(TestCase, TestMixin):
# THEN the dialog reject should have been called
assert mocked_reject.call_count == 1, 'The QDialog.reject should have been called'
def basic_accept_test(self):
def test_basic_accept(self):
"""
Test running the settings form and pressing Ok
"""
@ -94,7 +94,7 @@ class TestSettingsForm(TestCase, TestMixin):
# THEN the dialog reject should have been called
assert mocked_accept.call_count == 1, 'The QDialog.accept should have been called'
def basic_register_test(self):
def test_basic_register(self):
"""
Test running the settings form and adding a single function
"""
@ -109,7 +109,7 @@ class TestSettingsForm(TestCase, TestMixin):
# THEN the processing stack should be empty
assert len(self.form.processes) == 0, 'The one requested process should have been removed from the stack'
def register_multiple_functions_test(self):
def test_register_multiple_functions(self):
"""
Test running the settings form and adding multiple functions
"""

View File

@ -52,7 +52,7 @@ class TestShortcutform(TestCase, TestMixin):
del self.form
del self.main_window
def adjust_button_test(self):
def test_adjust_button(self):
"""
Test the _adjust_button() method
"""
@ -71,7 +71,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_check_method.assert_called_once_with(True)
self.assertEqual(button.isEnabled(), enabled, 'The button should be disabled.')
def space_key_press_event_test(self):
def test_space_key_press_event(self):
"""
Test the keyPressEvent when the spacebar was pressed
"""
@ -87,7 +87,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_key_release_event.assert_called_with(mocked_event)
self.assertEqual(0, mocked_event.accept.call_count)
def primary_push_button_checked_key_press_event_test(self):
def test_primary_push_button_checked_key_press_event(self):
"""
Test the keyPressEvent when the primary push button is checked
"""
@ -104,7 +104,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_key_release_event.assert_called_with(mocked_event)
self.assertEqual(0, mocked_event.accept.call_count)
def alternate_push_button_checked_key_press_event_test(self):
def test_alternate_push_button_checked_key_press_event(self):
"""
Test the keyPressEvent when the alternate push button is checked
"""
@ -121,7 +121,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_key_release_event.assert_called_with(mocked_event)
self.assertEqual(0, mocked_event.accept.call_count)
def escape_key_press_event_test(self):
def test_escape_key_press_event(self):
"""
Test the keyPressEvent when the escape key was pressed
"""
@ -137,7 +137,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_event.accept.assert_called_with()
mocked_close.assert_called_with()
def on_default_radio_button_not_toggled_test(self):
def test_on_default_radio_button_not_toggled(self):
"""
Test that the default radio button method exits early when the button is not toggled
"""
@ -150,7 +150,7 @@ class TestShortcutform(TestCase, TestMixin):
# THEN: The method should exit early (i.e. the rest of the methods are not called)
self.assertEqual(0, mocked_current_item_action.call_count)
def on_default_radio_button_clicked_no_action_test(self):
def test_on_default_radio_button_clicked_no_action(self):
"""
Test that nothing happens when an action hasn't been selected and you click the default radio button
"""
@ -166,7 +166,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_current_item_action.assert_called_with()
self.assertEqual(0, mocked_action_shortcuts.call_count)
def on_default_radio_button_clicked_test(self):
def test_on_default_radio_button_clicked(self):
"""
Test that the values are copied across correctly when the default radio button is selected
"""
@ -191,7 +191,7 @@ class TestShortcutform(TestCase, TestMixin):
mocked_refresh_shortcut_list.assert_called_with()
mocked_set_text.assert_called_with('Esc')
def on_custom_radio_button_not_toggled_test(self):
def test_on_custom_radio_button_not_toggled(self):
"""
Test that the custom radio button method exits early when the button is not toggled
"""
@ -204,7 +204,7 @@ class TestShortcutform(TestCase, TestMixin):
# THEN: The method should exit early (i.e. the rest of the methods are not called)
self.assertEqual(0, mocked_current_item_action.call_count)
def on_custom_radio_button_clicked_test(self):
def test_on_custom_radio_button_clicked(self):
"""
Test that the values are copied across correctly when the custom radio button is selected
"""

Some files were not shown because too many files have changed in this diff Show More