diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 913ad539c..368035e17 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -74,8 +74,8 @@ class ScreenList(object): screen_list.display_count = 0 screen_list.screen_count_changed() screen_list.load_screen_settings() - QtCore.QObject.connect(desktop, QtCore.SIGNAL(u'resized(int)'), screen_list.screen_resolution_changed) - QtCore.QObject.connect(desktop, QtCore.SIGNAL(u'screenCountChanged(int)'), screen_list.screen_count_changed) + desktop.resized.connect(screen_list.screen_resolution_changed) + desktop.screenCountChanged.connect(screen_list.screen_count_changed) return screen_list def screen_resolution_changed(self, number): diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index a2e80dc54..92f995122 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -53,13 +53,11 @@ them separate from the functionality, so that it is easier to recreate the GUI from the .ui files later if necessary. """ -from mediafilesform import MediaFilesForm -from authorsform import AuthorsForm -from topicsform import TopicsForm -from songbookform import SongBookForm -from editverseform import EditVerseForm -from editsongform import EditSongForm -from songmaintenanceform import SongMaintenanceForm -from songimportform import SongImportForm -from songexportform import SongExportForm - +# from mediafilesform import MediaFilesForm +# from authorsform import AuthorsForm +# from topicsform import TopicsForm +# from songbookform import SongBookForm +# from editsongform import EditSongForm +# from songmaintenanceform import SongMaintenanceForm +# from songimportform import SongImportForm +# from songexportform import SongExportForm diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index e95cd9d03..231dacca1 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -38,15 +38,14 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, PluginStatus, MediaType, translate, create_separated_list, \ - check_directory_exists, UiStrings -from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ - find_and_set_in_combo_box +from openlp.core.lib import Registry, PluginStatus, MediaType, UiStrings, translate, create_separated_list, \ + check_directory_exists +from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box from openlp.core.utils import AppLocation -from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm -from openlp.plugins.songs.lib import SongXML, VerseType, clean_song +from openlp.plugins.songs.lib import VerseType, clean_song from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile from openlp.plugins.songs.lib.ui import SongStrings +from openlp.plugins.songs.lib.xml import SongXML from openlp.plugins.songs.forms.editsongdialog import Ui_EditSongDialog log = logging.getLogger(__name__) @@ -62,6 +61,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Constructor """ + from openlp.plugins.songs.forms.editverseform import EditVerseForm + from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm + super(EditSongForm, self).__init__(parent) self.mediaitem = mediaitem self.song = None diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 743973a0c..b145c0e6a 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -33,7 +33,6 @@ import logging from PyQt4 import QtCore, QtGui from openlp.plugins.songs.lib import VerseType - from editversedialog import Ui_EditVerseDialog log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 690cfe25e..49ffde644 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -36,6 +36,7 @@ from mediafilesdialog import Ui_MediaFilesDialog log = logging.getLogger(__name__) + class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): """ Class to show a list of files from the diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index a3e5761d3..e40a2d56e 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -33,7 +33,9 @@ from sqlalchemy.sql import and_ from openlp.core.lib import Registry, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box -from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm +from openlp.plugins.songs.forms.authorsform import AuthorsForm +from openlp.plugins.songs.forms.topicsform import TopicsForm +from openlp.plugins.songs.forms.songbookform import SongBookForm from openlp.plugins.songs.lib.db import Author, Book, Topic, Song from songmaintenancedialog import Ui_SongMaintenanceDialog diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index e9c34a95b..ef8e9000d 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -185,7 +185,7 @@ class VerseType(object): for num, tag in enumerate(VerseType.tags): if verse_tag == tag: return VerseType.translated_tags[num].upper() - if len(VerseType.Names) > default: + if len(VerseType.names) > default: return VerseType.translated_tags[default].upper() else: return VerseType.translated_tags[VerseType.Other].upper() @@ -204,8 +204,8 @@ class VerseType(object): verse_tag = verse_tag[0].lower() for num, tag in enumerate(VerseType.tags): if verse_tag == tag: - return VerseType.TranslatedNames[num] - if len(VerseType.Names) > default: + return VerseType.translated_names[num] + if len(VerseType.names) > default: return VerseType.translated_names[default] else: return VerseType.translated_names[VerseType.Other] @@ -225,7 +225,7 @@ class VerseType(object): for num, tag in enumerate(VerseType.tags): if verse_tag == tag: return num - if len(VerseType.Names) > default: + if len(VerseType.names) > default: return default else: return VerseType.Other @@ -245,7 +245,7 @@ class VerseType(object): for num, tag in enumerate(VerseType.translated_tags): if verse_tag == tag: return num - if len(VerseType.Names) > default: + if len(VerseType.names) > default: return default else: return VerseType.Other @@ -625,6 +625,6 @@ def natcmp(a, b): return result return 1 -from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML -from openlp.plugins.songs.lib.songstab import SongsTab -from openlp.plugins.songs.lib.mediaitem import SongMediaItem +#from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML +#from openlp.plugins.songs.lib.songstab import SongsTab +#from openlp.plugins.songs.lib.mediaitem import SongMediaItem diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index da706bdcb..16a869b72 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -39,10 +39,14 @@ from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, Plugin UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists from openlp.core.lib.ui import create_widget_action from openlp.core.utils import AppLocation -from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, SongImportForm, SongExportForm -from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, clean_string, natcmp +from openlp.plugins.songs.forms.editsongform import EditSongForm +from openlp.plugins.songs.forms.songmaintenanceform import SongMaintenanceForm +from openlp.plugins.songs.forms.songimportform import SongImportForm +from openlp.plugins.songs.forms.songexportform import SongExportForm +from openlp.plugins.songs.lib import VerseType, clean_string, natcmp from openlp.plugins.songs.lib.db import Author, Song, Book, MediaFile from openlp.plugins.songs.lib.ui import SongStrings +from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index b1698418a..19a6c051a 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -37,10 +37,11 @@ from lxml import etree from openlp.core.lib import Registry, check_directory_exists, translate from openlp.core.utils import clean_filename -from openlp.plugins.songs.lib import OpenLyrics +from openlp.plugins.songs.lib.xml import OpenLyrics log = logging.getLogger(__name__) + class OpenLyricsExport(object): """ This provides the Openlyrics export. diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 199cb48ce..c957d4f5f 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -39,11 +39,11 @@ from lxml import etree from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings -from openlp.plugins.songs.lib import OpenLyrics -from openlp.plugins.songs.lib.xml import OpenLyricsError +from openlp.plugins.songs.lib.xml import OpenLyrics, OpenLyricsError log = logging.getLogger(__name__) + class OpenLyricsImport(SongImport): """ This provides the Openlyrics import. diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index ac8be3680..67382bb46 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -43,11 +43,13 @@ from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action from openlp.core.utils import get_filesystem_encoding from openlp.core.utils.actions import ActionList -from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, SongsTab +from openlp.plugins.songs.lib import clean_song, upgrade from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.mediaitem import SongSearch from openlp.plugins.songs.lib.importer import SongFormat from openlp.plugins.songs.lib.olpimport import OpenLPSongImport +from openlp.plugins.songs.lib.mediaitem import SongMediaItem +from openlp.plugins.songs.lib.songstab import SongsTab log = logging.getLogger(__name__) __default_settings__ = { diff --git a/tests/functional/openlp_core_lib/test_screen.py b/tests/functional/openlp_core_lib/test_screen.py index 4b4df8e9b..007889a12 100644 --- a/tests/functional/openlp_core_lib/test_screen.py +++ b/tests/functional/openlp_core_lib/test_screen.py @@ -23,11 +23,17 @@ class TestScreenList(TestCase): """ Set up the components need for all tests. """ + # Mocked out desktop object + self.desktop = MagicMock() + self.desktop.primaryScreen.return_value = SCREEN[u'primary'] + self.desktop.screenCount.return_value = SCREEN[u'number'] + self.desktop.screenGeometry.return_value = SCREEN[u'size'] + self.application = QtGui.QApplication.instance() Registry.create() self.application.setOrganizationName(u'OpenLP-tests') self.application.setOrganizationDomain(u'openlp.org') - self.screens = ScreenList.create(self.application.desktop()) + self.screens = ScreenList.create(self.desktop) def tearDown(self): """ @@ -38,21 +44,16 @@ class TestScreenList(TestCase): def add_desktop_test(self): """ - Test the ScreenList class' - screen_count_changed method to check if new monitors are detected by OpenLP. + Test the ScreenList.screen_count_changed method to check if new monitors are detected by OpenLP. """ - # GIVEN: The screen list. - old_screens = copy.deepcopy(self.screens.screen_list) - # Mock the attributes. - self.screens.desktop.primaryScreen = MagicMock(return_value=SCREEN[u'primary']) - self.screens.desktop.screenCount = MagicMock(return_value=SCREEN[u'number'] + 1) - self.screens.desktop.screenGeometry = MagicMock(return_value=SCREEN[u'size']) + # GIVEN: The screen list at its current size + old_screen_count = len(self.screens.screen_list) - # WHEN: Add a new screen. - self.screens.screen_count_changed(len(old_screens)) + # WHEN: We add a new screen + self.desktop.screenCount.return_value = SCREEN[u'number'] + 1 + self.screens.screen_count_changed(old_screen_count) - # THEN: The screen should have been added. - new_screens = self.screens.screen_list - assert len(old_screens) + 1 == len(new_screens), u'The new_screens list should be bigger.' - - # THEN: The screens should be identical. - assert SCREEN == new_screens.pop(), u'The new screen should be identical to the screen defined above.' + # THEN: The screen should have been added and the screens should be identical + new_screen_count = len(self.screens.screen_list) + assert old_screen_count + 1 == new_screen_count, u'The new_screens list should be bigger' + assert SCREEN == self.screens.screen_list.pop(), u'The 2nd screen should be identical to the first screen' diff --git a/tests/interfaces/__init__.py b/tests/interfaces/__init__.py index 0b5157b46..f14948f08 100644 --- a/tests/interfaces/__init__.py +++ b/tests/interfaces/__init__.py @@ -9,5 +9,5 @@ sip.setapi(u'QVariant', 2) from PyQt4 import QtGui -# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication. +# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" an QApplication. application = QtGui.QApplication([]) diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index b4b597356..6a046c80c 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -3,7 +3,8 @@ Package to test the openlp.core.lib.pluginmanager package. """ import os import sys -from tempfile import mkstemp +import shutil +from tempfile import mkstemp, mkdtemp from unittest import TestCase from mock import MagicMock @@ -23,7 +24,9 @@ class TestPluginManager(TestCase): Some pre-test setup required. """ fd, self.ini_file = mkstemp(u'.ini') + self.temp_dir = mkdtemp(u'openlp') Settings().set_filename(self.ini_file) + Settings().setValue(u'advanced/data path', self.temp_dir) Registry.create() Registry().register(u'service_list', MagicMock()) self.app = QtGui.QApplication.instance() @@ -31,9 +34,11 @@ class TestPluginManager(TestCase): Registry().register(u'main_window', self.main_window) def tearDown(self): - os.unlink(self.ini_file) del self.app del self.main_window + Settings().remove(u'advanced/data path') + shutil.rmtree(self.temp_dir) + os.unlink(self.ini_file) def find_plugins_test(self): """ diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py b/tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py index 8470da867..5d48c4de3 100644 --- a/tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py +++ b/tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py @@ -1,119 +1,117 @@ """ -Package to test the openlp.core.ui package. +Package to test the openlp.plugins.songs.forms.authorsform package. """ -## SHE IS NOT WORKING :-( +from unittest import TestCase + +from PyQt4 import QtGui + +from openlp.core.lib import Registry +from openlp.plugins.songs.forms.authorsform import AuthorsForm + + +class TestAuthorsForm(TestCase): + + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication.instance() + self.main_window = QtGui.QMainWindow() + Registry().register(u'main_window', self.main_window) + self.form = AuthorsForm() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.form + del self.main_window + del self.app + + def ui_defaults_test(self): + """ + Test the AuthorForm defaults are correct + """ + self.assertEqual(self.form.first_name_edit.text(), u'', u'The first name edit should be empty') + self.assertEqual(self.form.last_name_edit.text(), u'', u'The last name edit should be empty') + self.assertEqual(self.form.display_edit.text(), u'', u'The display name edit should be empty') + + def get_first_name_property_test(self): + """ + Test that getting the first name property on the AuthorForm works correctly. + """ + # GIVEN: A first name to set + first_name = u'John' + + # WHEN: The first_name_edit's text is set + self.form.first_name_edit.setText(first_name) + + # THEN: The first_name property should have the correct value + self.assertEqual(self.form.first_name, first_name, u'The first name property should be correct') + + def set_first_name_property_test(self): + """ + Test that setting the first name property on the AuthorForm works correctly. + """ + # GIVEN: A first name to set + first_name = u'James' + + # WHEN: The first_name property is set + self.form.first_name = first_name + + # THEN: The first_name_edit should have the correct value + self.assertEqual(self.form.first_name_edit.text(), first_name, u'The first name should be set correctly') + + def get_last_name_property_test(self): + """ + Test that getting the last name property on the AuthorForm works correctly. + """ + # GIVEN: A last name to set + last_name = u'Smith' + + # WHEN: The last_name_edit's text is set + self.form.last_name_edit.setText(last_name) + + # THEN: The last_name property should have the correct value + self.assertEqual(self.form.last_name, last_name, u'The last name property should be correct') + + def set_last_name_property_test(self): + """ + Test that setting the last name property on the AuthorForm works correctly. + """ + # GIVEN: A last name to set + last_name = u'Potter' + + # WHEN: The last_name property is set + self.form.last_name = last_name + + # THEN: The last_name_edit should have the correct value + self.assertEqual(self.form.last_name_edit.text(), last_name, u'The last name should be set correctly') + + def get_display_name_property_test(self): + """ + Test that getting the display name property on the AuthorForm works correctly. + """ + # GIVEN: A display name to set + display_name = u'John' + + # WHEN: The display_name_edit's text is set + self.form.display_edit.setText(display_name) + + # THEN: The display_name property should have the correct value + self.assertEqual(self.form.display_name, display_name, u'The display name property should be correct') + + def set_display_name_property_test(self): + """ + Test that setting the display name property on the AuthorForm works correctly. + """ + # GIVEN: A display name to set + display_name = u'John' + + # WHEN: The display_name property is set + self.form.display_name = display_name + + # THEN: The display_name_edit should have the correct value + self.assertEqual(self.form.display_edit.text(), display_name, u'The display name should be set correctly') -# from unittest import TestCase -# -# from PyQt4 import QtGui -# -# from openlp.core.lib import Registry -# from openlp.plugins.songs.forms.authorsform import AuthorsForm -# -# -# class TestAuthorsForm(TestCase): -# -# def setUp(self): -# """ -# Create the UI -# """ -# Registry.create() -# self.app = QtGui.QApplication([]) -# self.main_window = QtGui.QMainWindow() -# Registry().register(u'main_window', self.main_window) -# self.form = AuthorsForm() -# -# def tearDown(self): -# """ -# Delete all the C++ objects at the end so that we don't have a segfault -# """ -# del self.form -# del self.main_window -# del self.app -# -# def ui_defaults_test(self): -# """ -# Test the AuthorForm defaults are correct -# """ -# self.assertEqual(self.form.first_name_edit.text(), u'', u'The first name edit should be empty') -# self.assertEqual(self.form.last_name_edit.text(), u'', u'The last name edit should be empty') -# self.assertEqual(self.form.display_edit.text(), u'', u'The display name edit should be empty') -# -# def get_first_name_property_test(self): -# """ -# Test that getting the first name property on the AuthorForm works correctly. -# """ -# # GIVEN: A first name to set -# first_name = u'John' -# -# # WHEN: The first_name_edit's text is set -# self.form.first_name_edit.setText(first_name) -# -# # THEN: The first_name property should have the correct value -# self.assertEqual(self.form.first_name, first_name, u'The first name property should be correct') -# -# def set_first_name_property_test(self): -# """ -# Test that setting the first name property on the AuthorForm works correctly. -# """ -# # GIVEN: A first name to set -# first_name = u'James' -# -# # WHEN: The first_name property is set -# self.form.first_name = first_name -# -# # THEN: The first_name_edit should have the correct value -# self.assertEqual(self.form.first_name_edit.text(), first_name, u'The first name should be set correctly') -# -# def get_last_name_property_test(self): -# """ -# Test that getting the last name property on the AuthorForm works correctly. -# """ -# # GIVEN: A last name to set -# last_name = u'Smith' -# -# # WHEN: The last_name_edit's text is set -# self.form.last_name_edit.setText(last_name) -# -# # THEN: The last_name property should have the correct value -# self.assertEqual(self.form.last_name, last_name, u'The last name property should be correct') -# -# def set_last_name_property_test(self): -# """ -# Test that setting the last name property on the AuthorForm works correctly. -# """ -# # GIVEN: A last name to set -# last_name = u'Potter' -# -# # WHEN: The last_name property is set -# self.form.last_name = last_name -# -# # THEN: The last_name_edit should have the correct value -# self.assertEqual(self.form.last_name_edit.text(), last_name, u'The last name should be set correctly') -# -# def get_display_name_property_test(self): -# """ -# Test that getting the display name property on the AuthorForm works correctly. -# """ -# # GIVEN: A display name to set -# display_name = u'John' -# -# # WHEN: The display_name_edit's text is set -# self.form.display_edit.setText(display_name) -# -# # THEN: The display_name property should have the correct value -# self.assertEqual(self.form.display_name, display_name, u'The display name property should be correct') -# -# def set_display_name_property_test(self): -# """ -# Test that setting the display name property on the AuthorForm works correctly. -# """ -# # GIVEN: A display name to set -# display_name = u'John' -# -# # WHEN: The display_name property is set -# self.form.display_name = display_name -# -# # THEN: The display_name_edit should have the correct value -# self.assertEqual(self.form.display_edit.text(), display_name, u'The display name should be set correctly') -# diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_editsongform.py b/tests/interfaces/openlp_plugins_songs_forms/test_editsongform.py new file mode 100644 index 000000000..a84eb6e67 --- /dev/null +++ b/tests/interfaces/openlp_plugins_songs_forms/test_editsongform.py @@ -0,0 +1,40 @@ +""" +Package to test the openlp.plugins.songs.forms.editsongform package. +""" +from mock import MagicMock +from unittest import TestCase + +from PyQt4 import QtGui + +from openlp.core.lib import Registry +from openlp.plugins.songs.forms.editsongform import EditSongForm + + +class TestEditSongForm(TestCase): + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication.instance() + self.main_window = QtGui.QMainWindow() + Registry().register(u'main_window', self.main_window) + Registry().register(u'theme_manager', MagicMock()) + self.form = EditSongForm(MagicMock(), self.main_window, MagicMock()) + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.form + del self.main_window + del self.app + + def ui_defaults_test(self): + """ + Test that the EditSongForm defaults are correct + """ + self.assertFalse(self.form.verse_edit_button.isEnabled(), u'The verse edit button should not be enabled') + self.assertFalse(self.form.verse_delete_button.isEnabled(), u'The verse delete button should not be enabled') + self.assertFalse(self.form.author_remove_button.isEnabled(), u'The author remove button should not be enabled') + self.assertFalse(self.form.topic_remove_button.isEnabled(), u'The topic remove button should not be enabled') diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_editverseform.py b/tests/interfaces/openlp_plugins_songs_forms/test_editverseform.py new file mode 100644 index 000000000..cfd5ed0ef --- /dev/null +++ b/tests/interfaces/openlp_plugins_songs_forms/test_editverseform.py @@ -0,0 +1,35 @@ +""" +Package to test the openlp.plugins.songs.forms.editverseform package. +""" +from unittest import TestCase + +from PyQt4 import QtGui + +from openlp.core.lib import Registry +from openlp.plugins.songs.forms.editverseform import EditVerseForm + + +class TestEditVerseForm(TestCase): + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication.instance() + self.main_window = QtGui.QMainWindow() + Registry().register(u'main_window', self.main_window) + self.form = EditVerseForm() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.form + del self.main_window + del self.app + + def ui_defaults_test(self): + """ + Test the EditVerseForm defaults are correct + """ + self.assertEqual(self.form.verseTextEdit.toPlainText(), u'', u'The verse edit box is empty.')