forked from openlp/openlp
More cleanups and more tests
This commit is contained in:
parent
e5c87ed6f2
commit
87212e5d1c
@ -74,8 +74,8 @@ class ScreenList(object):
|
|||||||
screen_list.display_count = 0
|
screen_list.display_count = 0
|
||||||
screen_list.screen_count_changed()
|
screen_list.screen_count_changed()
|
||||||
screen_list.load_screen_settings()
|
screen_list.load_screen_settings()
|
||||||
QtCore.QObject.connect(desktop, QtCore.SIGNAL(u'resized(int)'), screen_list.screen_resolution_changed)
|
desktop.resized.connect(screen_list.screen_resolution_changed)
|
||||||
QtCore.QObject.connect(desktop, QtCore.SIGNAL(u'screenCountChanged(int)'), screen_list.screen_count_changed)
|
desktop.screenCountChanged.connect(screen_list.screen_count_changed)
|
||||||
return screen_list
|
return screen_list
|
||||||
|
|
||||||
def screen_resolution_changed(self, number):
|
def screen_resolution_changed(self, number):
|
||||||
|
@ -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 the .ui files later if necessary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from mediafilesform import MediaFilesForm
|
# from mediafilesform import MediaFilesForm
|
||||||
from authorsform import AuthorsForm
|
# from authorsform import AuthorsForm
|
||||||
from topicsform import TopicsForm
|
# from topicsform import TopicsForm
|
||||||
from songbookform import SongBookForm
|
# from songbookform import SongBookForm
|
||||||
from editverseform import EditVerseForm
|
# from editsongform import EditSongForm
|
||||||
from editsongform import EditSongForm
|
# from songmaintenanceform import SongMaintenanceForm
|
||||||
from songmaintenanceform import SongMaintenanceForm
|
# from songimportform import SongImportForm
|
||||||
from songimportform import SongImportForm
|
# from songexportform import SongExportForm
|
||||||
from songexportform import SongExportForm
|
|
||||||
|
|
||||||
|
@ -38,15 +38,14 @@ import shutil
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Registry, PluginStatus, MediaType, translate, create_separated_list, \
|
from openlp.core.lib import Registry, PluginStatus, MediaType, UiStrings, translate, create_separated_list, \
|
||||||
check_directory_exists, UiStrings
|
check_directory_exists
|
||||||
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \
|
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box
|
||||||
find_and_set_in_combo_box
|
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm
|
from openlp.plugins.songs.lib import VerseType, clean_song
|
||||||
from openlp.plugins.songs.lib import SongXML, VerseType, clean_song
|
|
||||||
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile
|
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.ui import SongStrings
|
||||||
|
from openlp.plugins.songs.lib.xml import SongXML
|
||||||
from openlp.plugins.songs.forms.editsongdialog import Ui_EditSongDialog
|
from openlp.plugins.songs.forms.editsongdialog import Ui_EditSongDialog
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -62,6 +61,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
|
from openlp.plugins.songs.forms.editverseform import EditVerseForm
|
||||||
|
from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm
|
||||||
|
|
||||||
super(EditSongForm, self).__init__(parent)
|
super(EditSongForm, self).__init__(parent)
|
||||||
self.mediaitem = mediaitem
|
self.mediaitem = mediaitem
|
||||||
self.song = None
|
self.song = None
|
||||||
|
@ -33,7 +33,6 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.plugins.songs.lib import VerseType
|
from openlp.plugins.songs.lib import VerseType
|
||||||
|
|
||||||
from editversedialog import Ui_EditVerseDialog
|
from editversedialog import Ui_EditVerseDialog
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -36,6 +36,7 @@ from mediafilesdialog import Ui_MediaFilesDialog
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog):
|
class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog):
|
||||||
"""
|
"""
|
||||||
Class to show a list of files from the
|
Class to show a list of files from the
|
||||||
|
@ -33,7 +33,9 @@ from sqlalchemy.sql import and_
|
|||||||
|
|
||||||
from openlp.core.lib import Registry, UiStrings, translate
|
from openlp.core.lib import Registry, UiStrings, translate
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
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 openlp.plugins.songs.lib.db import Author, Book, Topic, Song
|
||||||
from songmaintenancedialog import Ui_SongMaintenanceDialog
|
from songmaintenancedialog import Ui_SongMaintenanceDialog
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class VerseType(object):
|
|||||||
for num, tag in enumerate(VerseType.tags):
|
for num, tag in enumerate(VerseType.tags):
|
||||||
if verse_tag == tag:
|
if verse_tag == tag:
|
||||||
return VerseType.translated_tags[num].upper()
|
return VerseType.translated_tags[num].upper()
|
||||||
if len(VerseType.Names) > default:
|
if len(VerseType.names) > default:
|
||||||
return VerseType.translated_tags[default].upper()
|
return VerseType.translated_tags[default].upper()
|
||||||
else:
|
else:
|
||||||
return VerseType.translated_tags[VerseType.Other].upper()
|
return VerseType.translated_tags[VerseType.Other].upper()
|
||||||
@ -204,8 +204,8 @@ class VerseType(object):
|
|||||||
verse_tag = verse_tag[0].lower()
|
verse_tag = verse_tag[0].lower()
|
||||||
for num, tag in enumerate(VerseType.tags):
|
for num, tag in enumerate(VerseType.tags):
|
||||||
if verse_tag == tag:
|
if verse_tag == tag:
|
||||||
return VerseType.TranslatedNames[num]
|
return VerseType.translated_names[num]
|
||||||
if len(VerseType.Names) > default:
|
if len(VerseType.names) > default:
|
||||||
return VerseType.translated_names[default]
|
return VerseType.translated_names[default]
|
||||||
else:
|
else:
|
||||||
return VerseType.translated_names[VerseType.Other]
|
return VerseType.translated_names[VerseType.Other]
|
||||||
@ -225,7 +225,7 @@ class VerseType(object):
|
|||||||
for num, tag in enumerate(VerseType.tags):
|
for num, tag in enumerate(VerseType.tags):
|
||||||
if verse_tag == tag:
|
if verse_tag == tag:
|
||||||
return num
|
return num
|
||||||
if len(VerseType.Names) > default:
|
if len(VerseType.names) > default:
|
||||||
return default
|
return default
|
||||||
else:
|
else:
|
||||||
return VerseType.Other
|
return VerseType.Other
|
||||||
@ -245,7 +245,7 @@ class VerseType(object):
|
|||||||
for num, tag in enumerate(VerseType.translated_tags):
|
for num, tag in enumerate(VerseType.translated_tags):
|
||||||
if verse_tag == tag:
|
if verse_tag == tag:
|
||||||
return num
|
return num
|
||||||
if len(VerseType.Names) > default:
|
if len(VerseType.names) > default:
|
||||||
return default
|
return default
|
||||||
else:
|
else:
|
||||||
return VerseType.Other
|
return VerseType.Other
|
||||||
@ -625,6 +625,6 @@ def natcmp(a, b):
|
|||||||
return result
|
return result
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML
|
#from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML
|
||||||
from openlp.plugins.songs.lib.songstab import SongsTab
|
#from openlp.plugins.songs.lib.songstab import SongsTab
|
||||||
from openlp.plugins.songs.lib.mediaitem import SongMediaItem
|
#from openlp.plugins.songs.lib.mediaitem import SongMediaItem
|
||||||
|
@ -39,10 +39,14 @@ from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, Plugin
|
|||||||
UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists
|
UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists
|
||||||
from openlp.core.lib.ui import create_widget_action
|
from openlp.core.lib.ui import create_widget_action
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, SongImportForm, SongExportForm
|
from openlp.plugins.songs.forms.editsongform import EditSongForm
|
||||||
from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, clean_string, natcmp
|
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.db import Author, Song, Book, MediaFile
|
||||||
from openlp.plugins.songs.lib.ui import SongStrings
|
from openlp.plugins.songs.lib.ui import SongStrings
|
||||||
|
from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -37,10 +37,11 @@ from lxml import etree
|
|||||||
|
|
||||||
from openlp.core.lib import Registry, check_directory_exists, translate
|
from openlp.core.lib import Registry, check_directory_exists, translate
|
||||||
from openlp.core.utils import clean_filename
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class OpenLyricsExport(object):
|
class OpenLyricsExport(object):
|
||||||
"""
|
"""
|
||||||
This provides the Openlyrics export.
|
This provides the Openlyrics export.
|
||||||
|
@ -39,11 +39,11 @@ from lxml import etree
|
|||||||
from openlp.core.ui.wizard import WizardStrings
|
from openlp.core.ui.wizard import WizardStrings
|
||||||
from openlp.plugins.songs.lib.songimport import SongImport
|
from openlp.plugins.songs.lib.songimport import SongImport
|
||||||
from openlp.plugins.songs.lib.ui import SongStrings
|
from openlp.plugins.songs.lib.ui import SongStrings
|
||||||
from openlp.plugins.songs.lib import OpenLyrics
|
from openlp.plugins.songs.lib.xml import OpenLyrics, OpenLyricsError
|
||||||
from openlp.plugins.songs.lib.xml import OpenLyricsError
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class OpenLyricsImport(SongImport):
|
class OpenLyricsImport(SongImport):
|
||||||
"""
|
"""
|
||||||
This provides the Openlyrics import.
|
This provides the Openlyrics import.
|
||||||
|
@ -43,11 +43,13 @@ from openlp.core.lib.db import Manager
|
|||||||
from openlp.core.lib.ui import create_action
|
from openlp.core.lib.ui import create_action
|
||||||
from openlp.core.utils import get_filesystem_encoding
|
from openlp.core.utils import get_filesystem_encoding
|
||||||
from openlp.core.utils.actions import ActionList
|
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.db import init_schema, Song
|
||||||
from openlp.plugins.songs.lib.mediaitem import SongSearch
|
from openlp.plugins.songs.lib.mediaitem import SongSearch
|
||||||
from openlp.plugins.songs.lib.importer import SongFormat
|
from openlp.plugins.songs.lib.importer import SongFormat
|
||||||
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
__default_settings__ = {
|
__default_settings__ = {
|
||||||
|
@ -23,11 +23,17 @@ class TestScreenList(TestCase):
|
|||||||
"""
|
"""
|
||||||
Set up the components need for all tests.
|
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()
|
self.application = QtGui.QApplication.instance()
|
||||||
Registry.create()
|
Registry.create()
|
||||||
self.application.setOrganizationName(u'OpenLP-tests')
|
self.application.setOrganizationName(u'OpenLP-tests')
|
||||||
self.application.setOrganizationDomain(u'openlp.org')
|
self.application.setOrganizationDomain(u'openlp.org')
|
||||||
self.screens = ScreenList.create(self.application.desktop())
|
self.screens = ScreenList.create(self.desktop)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
@ -38,21 +44,16 @@ class TestScreenList(TestCase):
|
|||||||
|
|
||||||
def add_desktop_test(self):
|
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.
|
# GIVEN: The screen list at its current size
|
||||||
old_screens = copy.deepcopy(self.screens.screen_list)
|
old_screen_count = len(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'])
|
|
||||||
|
|
||||||
# WHEN: Add a new screen.
|
# WHEN: We add a new screen
|
||||||
self.screens.screen_count_changed(len(old_screens))
|
self.desktop.screenCount.return_value = SCREEN[u'number'] + 1
|
||||||
|
self.screens.screen_count_changed(old_screen_count)
|
||||||
|
|
||||||
# THEN: The screen should have been added.
|
# THEN: The screen should have been added and the screens should be identical
|
||||||
new_screens = self.screens.screen_list
|
new_screen_count = len(self.screens.screen_list)
|
||||||
assert len(old_screens) + 1 == len(new_screens), u'The new_screens list should be bigger.'
|
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'
|
||||||
# THEN: The screens should be identical.
|
|
||||||
assert SCREEN == new_screens.pop(), u'The new screen should be identical to the screen defined above.'
|
|
||||||
|
@ -9,5 +9,5 @@ sip.setapi(u'QVariant', 2)
|
|||||||
|
|
||||||
from PyQt4 import QtGui
|
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([])
|
application = QtGui.QApplication([])
|
||||||
|
@ -3,7 +3,8 @@ Package to test the openlp.core.lib.pluginmanager package.
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from tempfile import mkstemp
|
import shutil
|
||||||
|
from tempfile import mkstemp, mkdtemp
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
@ -23,7 +24,9 @@ class TestPluginManager(TestCase):
|
|||||||
Some pre-test setup required.
|
Some pre-test setup required.
|
||||||
"""
|
"""
|
||||||
fd, self.ini_file = mkstemp(u'.ini')
|
fd, self.ini_file = mkstemp(u'.ini')
|
||||||
|
self.temp_dir = mkdtemp(u'openlp')
|
||||||
Settings().set_filename(self.ini_file)
|
Settings().set_filename(self.ini_file)
|
||||||
|
Settings().setValue(u'advanced/data path', self.temp_dir)
|
||||||
Registry.create()
|
Registry.create()
|
||||||
Registry().register(u'service_list', MagicMock())
|
Registry().register(u'service_list', MagicMock())
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication.instance()
|
||||||
@ -31,9 +34,11 @@ class TestPluginManager(TestCase):
|
|||||||
Registry().register(u'main_window', self.main_window)
|
Registry().register(u'main_window', self.main_window)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.unlink(self.ini_file)
|
|
||||||
del self.app
|
del self.app
|
||||||
del self.main_window
|
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):
|
def find_plugins_test(self):
|
||||||
"""
|
"""
|
||||||
|
@ -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')
|
|
||||||
#
|
|
||||||
|
@ -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')
|
@ -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.')
|
Loading…
Reference in New Issue
Block a user