From 795977b094332b3664565b07e86fa56a89ad610c Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 23 Dec 2014 22:09:34 +0000 Subject: [PATCH] Make bible text parsing a bit more rebust, fixes bug 1404865. Fixes: https://launchpad.net/bugs/1404865 --- openlp/plugins/bibles/lib/http.py | 4 ++-- .../openlp_plugins/bibles/test_lib_http.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 37c858ab1..b840e0159 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -93,10 +93,10 @@ class BGExtract(RegistryProperties): """ if isinstance(tag, NavigableString): return None, str(tag) - elif tag.get('class')[0] == "versenum" or tag.get('class')[0] == 'versenum mid-line': + elif tag.get('class') and (tag.get('class')[0] == 'versenum' or tag.get('class')[0] == 'versenum mid-line'): verse = str(tag.string).replace('[', '').replace(']', '').strip() return verse, None - elif tag.get('class')[0] == 'chapternum': + elif tag.get('class') and tag.get('class')[0] == 'chapternum': verse = '1' return verse, None else: diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py index 9d72677ce..df38aed92 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py @@ -85,6 +85,19 @@ class TestBibleHTTP(TestCase): # 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' + 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' + def crosswalk_extract_books_test(self): """ Test Crosswalk retrieval of book list for NIV bible