2014-03-14 22:08:44 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2014 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
|
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
|
|
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
|
|
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2013-02-10 20:04:47 +00:00
|
|
|
"""
|
2013-03-07 12:34:35 +00:00
|
|
|
Package to test the openlp.plugins.songs.forms.authorsform package.
|
2013-02-10 20:04:47 +00:00
|
|
|
"""
|
2013-03-07 12:34:35 +00:00
|
|
|
from unittest import TestCase
|
|
|
|
|
2014-03-10 19:56:36 +00:00
|
|
|
from PyQt4 import QtGui, QtCore
|
2013-03-07 12:34:35 +00:00
|
|
|
|
2013-12-13 17:44:05 +00:00
|
|
|
from openlp.core.common import Registry
|
2013-03-07 12:34:35 +00:00
|
|
|
from openlp.plugins.songs.forms.authorsform import AuthorsForm
|
2014-03-14 22:08:44 +00:00
|
|
|
from tests.helpers.testmixin import TestMixin
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
|
2014-03-14 22:08:44 +00:00
|
|
|
class TestAuthorsForm(TestCase, TestMixin):
|
2013-03-14 22:22:18 +00:00
|
|
|
"""
|
|
|
|
Test the AuthorsForm class
|
|
|
|
"""
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
Create the UI
|
|
|
|
"""
|
|
|
|
Registry.create()
|
2014-03-14 22:08:44 +00:00
|
|
|
self.get_application()
|
2013-03-07 12:34:35 +00:00
|
|
|
self.main_window = QtGui.QMainWindow()
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register('main_window', self.main_window)
|
2013-03-07 12:34:35 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
def ui_defaults_test(self):
|
|
|
|
"""
|
|
|
|
Test the AuthorForm defaults are correct
|
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.first_name_edit.text(), '', 'The first name edit should be empty')
|
|
|
|
self.assertEqual(self.form.last_name_edit.text(), '', 'The last name edit should be empty')
|
|
|
|
self.assertEqual(self.form.display_edit.text(), '', 'The display name edit should be empty')
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def get_first_name_property_test(self):
|
|
|
|
"""
|
2013-03-11 21:10:29 +00:00
|
|
|
Test that getting the first name property on the AuthorForm works correctly
|
2013-03-07 12:34:35 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A first name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
first_name = 'John'
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
# 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
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.first_name, first_name, 'The first name property should be correct')
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def set_first_name_property_test(self):
|
|
|
|
"""
|
2013-03-11 21:10:29 +00:00
|
|
|
Test that setting the first name property on the AuthorForm works correctly
|
2013-03-07 12:34:35 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A first name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
first_name = 'James'
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
# WHEN: The first_name property is set
|
|
|
|
self.form.first_name = first_name
|
|
|
|
|
|
|
|
# THEN: The first_name_edit should have the correct value
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.first_name_edit.text(), first_name, 'The first name should be set correctly')
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def get_last_name_property_test(self):
|
|
|
|
"""
|
2013-03-11 21:10:29 +00:00
|
|
|
Test that getting the last name property on the AuthorForm works correctly
|
2013-03-07 12:34:35 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A last name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
last_name = 'Smith'
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
# 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
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.last_name, last_name, 'The last name property should be correct')
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def set_last_name_property_test(self):
|
|
|
|
"""
|
2013-03-11 21:10:29 +00:00
|
|
|
Test that setting the last name property on the AuthorForm works correctly
|
2013-03-07 12:34:35 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A last name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
last_name = 'Potter'
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
# WHEN: The last_name property is set
|
|
|
|
self.form.last_name = last_name
|
|
|
|
|
|
|
|
# THEN: The last_name_edit should have the correct value
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.last_name_edit.text(), last_name, 'The last name should be set correctly')
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def get_display_name_property_test(self):
|
|
|
|
"""
|
2013-03-11 21:10:29 +00:00
|
|
|
Test that getting the display name property on the AuthorForm works correctly
|
2013-03-07 12:34:35 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A display name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
display_name = 'John'
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
# 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
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.display_name, display_name, 'The display name property should be correct')
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
def set_display_name_property_test(self):
|
|
|
|
"""
|
2013-03-11 21:10:29 +00:00
|
|
|
Test that setting the display name property on the AuthorForm works correctly
|
2013-03-07 12:34:35 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A display name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
display_name = 'John'
|
2013-03-07 12:34:35 +00:00
|
|
|
|
|
|
|
# WHEN: The display_name property is set
|
|
|
|
self.form.display_name = display_name
|
|
|
|
|
|
|
|
# THEN: The display_name_edit should have the correct value
|
2013-08-31 18:17:38 +00:00
|
|
|
self.assertEqual(self.form.display_edit.text(), display_name, 'The display name should be set correctly')
|