From 83b30799ca41ca3e444f4896ea96b67102f1bc4f Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 11 Aug 2016 20:34:55 +0100 Subject: [PATCH] finished up with tests --- .../bibles/lib/{importers => }/http.py | 0 .../bibles/lib/importers/biblegateway.py | 4 +- .../bibles/lib/importers/bibleserver.py | 2 +- .../plugins/bibles/lib/importers/crosswalk.py | 4 +- openlp/plugins/bibles/lib/manager.py | 2 +- .../{test_http.py => test_bibleserver.py} | 43 ++++--------------- 6 files changed, 14 insertions(+), 41 deletions(-) rename openlp/plugins/bibles/lib/{importers => }/http.py (100%) rename tests/functional/openlp_plugins/bibles/{test_http.py => test_bibleserver.py} (88%) diff --git a/openlp/plugins/bibles/lib/importers/http.py b/openlp/plugins/bibles/lib/http.py similarity index 100% rename from openlp/plugins/bibles/lib/importers/http.py rename to openlp/plugins/bibles/lib/http.py diff --git a/openlp/plugins/bibles/lib/importers/biblegateway.py b/openlp/plugins/bibles/lib/importers/biblegateway.py index c6a8074bf..f3caa2204 100644 --- a/openlp/plugins/bibles/lib/importers/biblegateway.py +++ b/openlp/plugins/bibles/lib/importers/biblegateway.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. +The :mod:`biblegateway` module enables OpenLP to retrieve scripture from http://biblegateway.com. """ import logging import socket @@ -32,7 +32,7 @@ from bs4 import BeautifulSoup, NavigableString, Tag from openlp.core.common import RegistryProperties from openlp.core.lib.webpagereader import get_web_page from openlp.plugins.bibles.lib import SearchResults -from openlp.plugins.bibles.lib.importers.http import get_soup_for_bible_ref, send_error_message +from openlp.plugins.bibles.lib.http import get_soup_for_bible_ref, send_error_message UGLY_CHARS = { '\u2014': ' - ', diff --git a/openlp/plugins/bibles/lib/importers/bibleserver.py b/openlp/plugins/bibles/lib/importers/bibleserver.py index e651b84ab..16924d84a 100644 --- a/openlp/plugins/bibles/lib/importers/bibleserver.py +++ b/openlp/plugins/bibles/lib/importers/bibleserver.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. +The :mod:`bibleserver` module enables OpenLP to retrieve scripture from http://bibleserver.com. """ import logging import re diff --git a/openlp/plugins/bibles/lib/importers/crosswalk.py b/openlp/plugins/bibles/lib/importers/crosswalk.py index 6c75209d1..fb354dd29 100644 --- a/openlp/plugins/bibles/lib/importers/crosswalk.py +++ b/openlp/plugins/bibles/lib/importers/crosswalk.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. +The :mod:`crosswalk` module enables OpenLP to retrieve scripture from www.biblestudytools.com. """ import logging import re @@ -30,7 +30,7 @@ import urllib.error from openlp.core.common import RegistryProperties from openlp.plugins.bibles.lib import SearchResults -from openlp.plugins.bibles.lib.importers.http import get_soup_for_bible_ref, send_error_message +from openlp.plugins.bibles.lib.http import get_soup_for_bible_ref, send_error_message FIX_PUNKCTUATION_REGEX = re.compile(r'[ ]+([.,;])') REDUCE_SPACES_REGEX = re.compile(r'[ ]{2,}') diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index d2286bed2..2734411f5 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -27,7 +27,7 @@ from openlp.core.common import RegistryProperties, AppLocation, Settings, transl from openlp.plugins.bibles.lib import parse_reference, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from .importers.csvbible import CSVBible -from .importers.http import HTTPBible +from .http import HTTPBible from .importers.opensong import OpenSongBible from .importers.osis import OSISBible from .importers.zefania import ZefaniaBible diff --git a/tests/functional/openlp_plugins/bibles/test_http.py b/tests/functional/openlp_plugins/bibles/test_bibleserver.py similarity index 88% rename from tests/functional/openlp_plugins/bibles/test_http.py rename to tests/functional/openlp_plugins/bibles/test_bibleserver.py index 839c81008..0849a63e3 100644 --- a/tests/functional/openlp_plugins/bibles/test_http.py +++ b/tests/functional/openlp_plugins/bibles/test_bibleserver.py @@ -20,41 +20,13 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -This module contains tests for the http module of the Bibles plugin. +This module contains tests for the bibleserver module of the Bibles plugin. """ from unittest import TestCase from bs4 import BeautifulSoup from tests.functional import patch, MagicMock -from openlp.plugins.bibles.lib.importers.http import BSExtract - -# TODO: Items left to test -# BGExtract -# __init__ -# _remove_elements -# _extract_verse -# _clean_soup -# _extract_verses -# _extract_verses_old -# get_bible_chapter -# get_books_from_http -# _get_application -# CWExtract -# __init__ -# get_bible_chapter -# get_books_from_http -# _get_application -# HTTPBible -# __init__ -# do_import -# get_verses -# get_chapter -# get_books -# get_chapter_count -# get_verse_count -# _get_application -# get_soup_for_bible_ref -# send_error_message +from openlp.plugins.bibles.lib.importers.bibleserver import BSExtract class TestBSExtract(TestCase): @@ -68,11 +40,12 @@ class TestBSExtract(TestCase): # get_books_from_http # _get_application def setUp(self): - self.get_soup_for_bible_ref_patcher = patch('openlp.plugins.bibles.lib.importers.http.get_soup_for_bible_ref') - self.log_patcher = patch('openlp.plugins.bibles.lib.importers.http.log') - self.send_error_message_patcher = patch('openlp.plugins.bibles.lib.importers.http.send_error_message') - self.socket_patcher = patch('openlp.plugins.bibles.lib.importers.http.socket') - self.urllib_patcher = patch('openlp.plugins.bibles.lib.importers.http.urllib') + self.get_soup_for_bible_ref_patcher = patch( + 'openlp.plugins.bibles.lib.importers.bibleserver.get_soup_for_bible_ref') + self.log_patcher = patch('openlp.plugins.bibles.lib.importers.bibleserver.log') + self.send_error_message_patcher = patch('openlp.plugins.bibles.lib.importers.bibleserver.send_error_message') + self.socket_patcher = patch('openlp.plugins.bibles.lib.http.socket') + self.urllib_patcher = patch('openlp.plugins.bibles.lib.importers.bibleserver.urllib') self.mock_get_soup_for_bible_ref = self.get_soup_for_bible_ref_patcher.start() self.mock_log = self.log_patcher.start()