openlp/tests/functional/openlp_plugins/songs/test_editverseform.py

71 lines
3.2 KiB
Python
Raw Normal View History

2015-03-02 19:21:41 +00:00
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2015-12-31 22:46:06 +00:00
# Copyright (c) 2008-2016 OpenLP Developers #
2015-03-02 19:21:41 +00:00
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
2015-02-23 18:30:45 +00:00
"""
This module contains tests for the editverseform of the Songs plugin.
"""
from unittest import TestCase
2015-11-07 00:49:40 +00:00
from PyQt5 import QtCore, QtWidgets
2015-02-23 18:30:45 +00:00
from openlp.core.common import Registry, Settings
from openlp.core.lib import ServiceItem
from openlp.plugins.songs.forms.editverseform import EditVerseForm
from openlp.plugins.songs.lib.db import AuthorType
from tests.functional import patch, MagicMock
from tests.helpers.testmixin import TestMixin
class TestEditVerseForm(TestCase, TestMixin):
"""
Test the functions in the :mod:`lib` module.
"""
def setUp(self):
"""
Set up the components need for all tests.
"""
self.edit_verse_form = EditVerseForm(None)
self.setup_application()
self.build_settings()
QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))
def tearDown(self):
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
self.destroy_settings()
def update_suggested_verse_number_test(self):
"""
2015-02-27 19:33:49 +00:00
Test that update_suggested_verse_number() has no effect when editing a single verse
2015-02-23 18:30:45 +00:00
"""
# GIVEN some input values
self.edit_verse_form.has_single_verse = True
2015-03-02 19:21:41 +00:00
self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=0)
self.edit_verse_form.verse_text_edit.toPlainText = MagicMock(return_value='Text')
2015-02-23 18:30:45 +00:00
self.edit_verse_form.verse_number_box.setValue(3)
2015-03-02 19:21:41 +00:00
2015-02-23 18:30:45 +00:00
# WHEN the method is called
self.edit_verse_form.update_suggested_verse_number()
2015-03-02 19:21:41 +00:00
2015-02-23 18:30:45 +00:00
# THEN the verse number must not be changed
self.assertEqual(3, self.edit_verse_form.verse_number_box.value(), 'The verse number should be 3')