2014-03-11 19:01:09 +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 #
|
2014-03-11 19:01:09 +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 #
|
|
|
|
###############################################################################
|
2013-06-15 20:51:11 +00:00
|
|
|
"""
|
|
|
|
Package to test the openlp.plugin.bible.lib.https package.
|
|
|
|
"""
|
|
|
|
from unittest import TestCase
|
|
|
|
|
2013-12-13 17:44:05 +00:00
|
|
|
from openlp.core.common import Registry
|
2015-02-17 22:58:29 +00:00
|
|
|
from openlp.plugins.bibles.lib.http import BGExtract, CWExtract, BSExtract
|
2013-10-04 21:45:38 +00:00
|
|
|
from tests.interfaces import MagicMock
|
2013-06-15 20:51:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestBibleHTTP(TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
Set up the Registry
|
|
|
|
"""
|
|
|
|
Registry.create()
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register('service_list', MagicMock())
|
|
|
|
Registry().register('application', MagicMock())
|
2013-06-15 20:51:11 +00:00
|
|
|
|
2013-06-16 07:54:16 +00:00
|
|
|
def bible_gateway_extract_books_test(self):
|
2013-06-15 20:51:11 +00:00
|
|
|
"""
|
2013-06-16 07:54:16 +00:00
|
|
|
Test the Bible Gateway retrieval of book list for NIV bible
|
2013-06-15 20:51:11 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = BGExtract()
|
|
|
|
|
|
|
|
# WHEN: The Books list is called
|
2013-08-31 18:17:38 +00:00
|
|
|
books = handler.get_books_from_http('NIV')
|
2013-06-15 20:51:11 +00:00
|
|
|
|
|
|
|
# THEN: We should get back a valid service item
|
2013-08-31 18:17:38 +00:00
|
|
|
assert len(books) == 66, 'The bible should not have had any books added or removed'
|
2013-06-16 07:54:16 +00:00
|
|
|
|
2014-08-27 08:43:18 +00:00
|
|
|
def bible_gateway_extract_books_support_redirect_test(self):
|
|
|
|
"""
|
|
|
|
Test the Bible Gateway retrieval of book list for DN1933 bible with redirect (bug 1251437)
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = BGExtract()
|
|
|
|
|
|
|
|
# WHEN: The Books list is called
|
|
|
|
books = handler.get_books_from_http('DN1933')
|
|
|
|
|
|
|
|
# THEN: We should get back a valid service item
|
|
|
|
assert len(books) == 66, 'This bible should have 66 books'
|
|
|
|
|
2013-06-16 07:54:16 +00:00
|
|
|
def bible_gateway_extract_verse_test(self):
|
|
|
|
"""
|
|
|
|
Test the Bible Gateway retrieval of verse list for NIV bible John 3
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = BGExtract()
|
|
|
|
|
|
|
|
# WHEN: The Books list is called
|
2013-08-31 18:17:38 +00:00
|
|
|
results = handler.get_bible_chapter('NIV', 'John', 3)
|
2013-06-16 07:54:16 +00:00
|
|
|
|
|
|
|
# THEN: We should get back a valid service item
|
2013-09-09 21:10:40 +00:00
|
|
|
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
|
2014-12-23 22:09:34 +00:00
|
|
|
|
|
|
|
def bible_gateway_extract_verse_nkjv_test(self):
|
|
|
|
"""
|
|
|
|
Test the Bible Gateway retrieval of verse list for NKJV bible John 3
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = BGExtract()
|
|
|
|
|
|
|
|
# WHEN: The Books list is called
|
|
|
|
results = handler.get_bible_chapter('NKJV', 'John', 3)
|
|
|
|
|
|
|
|
# THEN: We should get back a valid service item
|
|
|
|
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
|
2013-06-16 07:54:16 +00:00
|
|
|
|
|
|
|
def crosswalk_extract_books_test(self):
|
|
|
|
"""
|
|
|
|
Test Crosswalk retrieval of book list for NIV bible
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = CWExtract()
|
|
|
|
|
|
|
|
# WHEN: The Books list is called
|
2013-08-31 18:17:38 +00:00
|
|
|
books = handler.get_books_from_http('niv')
|
2013-06-16 07:54:16 +00:00
|
|
|
|
|
|
|
# THEN: We should get back a valid service item
|
2013-08-31 18:17:38 +00:00
|
|
|
assert len(books) == 66, 'The bible should not have had any books added or removed'
|
2013-06-16 07:54:16 +00:00
|
|
|
|
|
|
|
def crosswalk_extract_verse_test(self):
|
|
|
|
"""
|
2013-06-16 13:36:09 +00:00
|
|
|
Test Crosswalk retrieval of verse list for NIV bible John 3
|
2013-06-16 07:54:16 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = CWExtract()
|
|
|
|
|
|
|
|
# WHEN: The Books list is called
|
2013-08-31 18:17:38 +00:00
|
|
|
results = handler.get_bible_chapter('niv', 'john', 3)
|
2013-06-16 07:54:16 +00:00
|
|
|
|
|
|
|
# THEN: We should get back a valid service item
|
2013-09-09 21:10:40 +00:00
|
|
|
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
|
2015-02-17 22:58:29 +00:00
|
|
|
|
|
|
|
def bibleserver_get_bibles_test(self):
|
|
|
|
"""
|
2015-05-25 20:03:31 +00:00
|
|
|
Test getting list of bibles from BibleServer.com
|
2015-02-17 22:58:29 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Server extraction class
|
|
|
|
handler = BSExtract()
|
|
|
|
|
2015-02-26 20:58:54 +00:00
|
|
|
# WHEN: downloading bible list from bibleserver
|
|
|
|
bibles = handler.get_bibles_from_http()
|
|
|
|
|
|
|
|
# THEN: The list should not be None, and some known bibles should be there
|
|
|
|
self.assertIsNotNone(bibles)
|
|
|
|
self.assertIn(('New Int. Readers Version', 'NIRV', 'en'), bibles)
|
2016-01-07 21:38:13 +00:00
|
|
|
self.assertIn(('Священное Писание, Восточный перевод', 'CARS', 'ru'), bibles)
|
2015-02-17 22:58:29 +00:00
|
|
|
|
|
|
|
def biblegateway_get_bibles_test(self):
|
|
|
|
"""
|
2015-05-25 20:03:31 +00:00
|
|
|
Test getting list of bibles from BibleGateway.com
|
2015-02-17 22:58:29 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: A new Bible Gateway extraction class
|
|
|
|
handler = BGExtract()
|
|
|
|
|
2015-02-26 20:58:54 +00:00
|
|
|
# WHEN: downloading bible list from Crosswalk
|
|
|
|
bibles = handler.get_bibles_from_http()
|
|
|
|
|
|
|
|
# THEN: The list should not be None, and some known bibles should be there
|
|
|
|
self.assertIsNotNone(bibles)
|
|
|
|
self.assertIn(('Holman Christian Standard Bible', 'HCSB', 'en'), bibles)
|
2015-02-17 22:58:29 +00:00
|
|
|
|
|
|
|
def crosswalk_get_bibles_test(self):
|
|
|
|
"""
|
|
|
|
Test getting list of bibles from Crosswalk.com
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Crosswalk extraction class
|
|
|
|
handler = CWExtract()
|
|
|
|
|
2015-02-26 20:58:54 +00:00
|
|
|
# WHEN: downloading bible list from Crosswalk
|
|
|
|
bibles = handler.get_bibles_from_http()
|
|
|
|
|
|
|
|
# THEN: The list should not be None, and some known bibles should be there
|
|
|
|
self.assertIsNotNone(bibles)
|
|
|
|
self.assertIn(('Giovanni Diodati 1649 (Italian)', 'gdb', 'it'), bibles)
|