2013-09-19 21:02:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2013 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-08-31 20:04:36 +00:00
|
|
|
"""
|
|
|
|
This module contains tests for the versereferencelist submodule of the Bibles plugin.
|
|
|
|
"""
|
|
|
|
from unittest import TestCase
|
2013-09-19 21:02:28 +00:00
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
from openlp.plugins.bibles.lib.versereferencelist import VerseReferenceList
|
|
|
|
|
2013-09-19 21:02:28 +00:00
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
class TestVerseReferenceList(TestCase):
|
2013-09-19 21:02:28 +00:00
|
|
|
"""
|
|
|
|
Test the VerseReferenceList class
|
|
|
|
"""
|
2013-08-31 20:04:36 +00:00
|
|
|
def add_first_verse_test(self):
|
|
|
|
"""
|
|
|
|
Test the addition of a verse to the empty list
|
|
|
|
"""
|
|
|
|
# GIVEN: an empty list
|
|
|
|
reference_list = VerseReferenceList()
|
|
|
|
book = 'testBook'
|
|
|
|
chapter = 1
|
|
|
|
verse = 1
|
|
|
|
version = 'testVersion'
|
2013-09-19 21:02:28 +00:00
|
|
|
copyright_ = 'testCopyright'
|
2013-08-31 20:04:36 +00:00
|
|
|
permission = 'testPermision'
|
2013-09-19 21:02:28 +00:00
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# WHEN: We add it to the verse list
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add(book, chapter, verse, version, copyright_, permission)
|
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# THEN: The entries should be in the first entry of the list
|
|
|
|
self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
|
|
|
|
self.assertEqual(reference_list.verse_list[0]['book'], book, 'The book in first entry should be %s' % book)
|
|
|
|
self.assertEqual(reference_list.verse_list[0]['chapter'], chapter, 'The chapter in first entry should be %u' % chapter)
|
|
|
|
self.assertEqual(reference_list.verse_list[0]['start'], verse, 'The start in first entry should be %u' % verse)
|
|
|
|
self.assertEqual(reference_list.verse_list[0]['version'], version, 'The version in first entry should be %s' % version)
|
|
|
|
self.assertEqual(reference_list.verse_list[0]['end'], verse, 'The end in first entry should be %u' % verse)
|
2013-09-19 21:02:28 +00:00
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
def add_next_verse_test(self):
|
|
|
|
"""
|
|
|
|
Test the addition of the following verse
|
|
|
|
"""
|
|
|
|
# GIVEN: 1 line in the list of verses
|
|
|
|
book = 'testBook'
|
|
|
|
chapter = 1
|
|
|
|
verse = 1
|
|
|
|
next_verse = 2
|
|
|
|
version = 'testVersion'
|
2013-09-19 21:02:28 +00:00
|
|
|
copyright_ = 'testCopyright'
|
2013-08-31 20:04:36 +00:00
|
|
|
permission = 'testPermision'
|
|
|
|
reference_list = VerseReferenceList()
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add(book, chapter, verse, version, copyright_, permission)
|
2013-08-31 20:04:36 +00:00
|
|
|
|
|
|
|
# WHEN: We add the following verse to the verse list
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add(book, chapter, next_verse, version, copyright_, permission)
|
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# THEN: The current index should be 0 and the end pointer of the entry should be '2'
|
|
|
|
self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
|
2013-10-02 21:37:00 +00:00
|
|
|
self.assertEqual(reference_list.verse_list[0]['end'], next_verse,
|
|
|
|
'The end in first entry should be %u' % next_verse)
|
2013-08-31 20:04:36 +00:00
|
|
|
|
|
|
|
def add_another_verse_test(self):
|
|
|
|
"""
|
|
|
|
Test the addition of a verse in another book
|
|
|
|
"""
|
|
|
|
# GIVEN: 1 line in the list of verses
|
|
|
|
book = 'testBook'
|
|
|
|
chapter = 1
|
|
|
|
verse = 1
|
|
|
|
another_book = 'testBook2'
|
|
|
|
another_chapter = 2
|
|
|
|
another_verse = 5
|
|
|
|
version = 'testVersion'
|
2013-09-19 21:02:28 +00:00
|
|
|
copyright_ = 'testCopyright'
|
2013-08-31 20:04:36 +00:00
|
|
|
permission = 'testPermision'
|
|
|
|
reference_list = VerseReferenceList()
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add(book, chapter, verse, version, copyright_, permission)
|
2013-08-31 20:04:36 +00:00
|
|
|
|
|
|
|
# WHEN: We add a verse of another book to the verse list
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add(another_book, another_chapter, another_verse, version, copyright_, permission)
|
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# 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):
|
|
|
|
"""
|
|
|
|
Test the addition of a version to the list
|
|
|
|
"""
|
|
|
|
# GIVEN: version, copyright and permission
|
|
|
|
reference_list = VerseReferenceList()
|
|
|
|
version = 'testVersion'
|
2013-09-19 21:02:28 +00:00
|
|
|
copyright_ = 'testCopyright'
|
2013-08-31 20:04:36 +00:00
|
|
|
permission = 'testPermision'
|
|
|
|
|
|
|
|
# WHEN: a not existing version will be added
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add_version(version, copyright_, permission)
|
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# THEN: the data will be appended to the list
|
|
|
|
self.assertEqual(len(reference_list.version_list), 1, 'The version data should be appended')
|
2013-09-19 21:02:28 +00:00
|
|
|
self.assertEqual(reference_list.version_list[0],
|
2013-10-02 21:37:00 +00:00
|
|
|
{'version': version, 'copyright': copyright_, 'permission': permission},
|
|
|
|
'The version data should be appended')
|
2013-09-19 21:02:28 +00:00
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
def add_existing_version_test(self):
|
|
|
|
"""
|
|
|
|
Test the addition of an existing version to the list
|
|
|
|
"""
|
|
|
|
# GIVEN: version, copyright and permission, added to the version list
|
|
|
|
reference_list = VerseReferenceList()
|
|
|
|
version = 'testVersion'
|
2013-09-19 21:02:28 +00:00
|
|
|
copyright_ = 'testCopyright'
|
2013-08-31 20:04:36 +00:00
|
|
|
permission = 'testPermision'
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add_version(version, copyright_, permission)
|
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# WHEN: an existing version will be added
|
2013-09-19 21:02:28 +00:00
|
|
|
reference_list.add_version(version, copyright_, permission)
|
|
|
|
|
2013-08-31 20:04:36 +00:00
|
|
|
# THEN: the data will not be appended to the list
|
|
|
|
self.assertEqual(len(reference_list.version_list), 1, 'The version data should not be appended')
|