← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-1212801 into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-1212801 into lp:openlp.

Commit message:
Fix bug #1212801 where the song edit form did not clear a previously set theme.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1212801 in OpenLP: "Theme in Song Editor is Never Reset"
  https://bugs.launchpad.net/openlp/+bug/1212801

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-1212801/+merge/180408

Fix bug #1212801 where the song edit form did not clear a previously set theme.
-- 
https://code.launchpad.net/~raoul-snyman/openlp/bug-1212801/+merge/180408
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/bug-1212801 into lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py	2013-04-18 17:45:14 +0000
+++ openlp/plugins/bibles/lib/__init__.py	2013-08-15 19:58:41 +0000
@@ -221,6 +221,7 @@
         u'(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \
         % dict(REFERENCE_SEPARATORS.items() + [(u'range_regex', range_regex)]), re.UNICODE)
 
+
 def get_reference_separator(separator_type):
     """
     Provides separators for parsing and formatting scripture references.
@@ -232,6 +233,7 @@
         update_reference_separators()
     return REFERENCE_SEPARATORS[separator_type]
 
+
 def get_reference_match(match_type):
     """
     Provides matches for parsing scripture references strings.
@@ -243,6 +245,7 @@
         update_reference_separators()
     return REFERENCE_MATCHES[match_type]
 
+
 def parse_reference(reference, bible, language_selection, book_ref_id=False):
     """
     This is the next generation über-awesome function that takes a person's typed in string and converts it to a list
@@ -402,7 +405,7 @@
     """
     Encapsulate a set of search results. This is Bible-type independent.
     """
-    def __init__(self, book, chapter, verselist):
+    def __init__(self, book, chapter, verse_list):
         """
         Create the search result object.
 
@@ -412,19 +415,19 @@
         ``chapter``
             The chapter of the book.
 
-        ``verselist``
+        ``verse_list``
             The list of verses for this reading.
 
         """
         self.book = book
         self.chapter = chapter
-        self.verselist = verselist
+        self.verse_list = verse_list
 
-    def has_verselist(self):
+    def has_verse_list(self):
         """
         Returns whether or not the verse list contains verses.
         """
-        return len(self.verselist) > 0
+        return len(self.verse_list) > 0
 
 
 from versereferencelist import VerseReferenceList

=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2013-06-30 05:45:34 +0000
+++ openlp/plugins/bibles/lib/http.py	2013-08-15 19:58:41 +0000
@@ -618,7 +618,7 @@
             if BibleDB.get_verse_count(self, book_id, reference[1]) == 0:
                 self.application.set_busy_cursor()
                 search_results = self.get_chapter(book, reference[1])
-                if search_results and search_results.has_verselist():
+                if search_results and search_results.has_verse_list():
                     ## We have found a book of the bible lets check to see
                     ## if it was there. By reusing the returned book name
                     ## we get a correct book. For example it is possible
@@ -627,7 +627,7 @@
                     self.application.process_events()
                     # Check to see if book/chapter exists.
                     db_book = self.get_book(book_name)
-                    self.create_chapter(db_book.id, search_results.chapter, search_results.verselist)
+                    self.create_chapter(db_book.id, search_results.chapter, search_results.verse_list)
                     self.application.process_events()
                 self.application.set_normal_cursor()
             self.application.process_events()

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2013-06-21 18:13:59 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2013-08-15 19:58:41 +0000
@@ -348,6 +348,7 @@
         self.load_topics()
         self.load_books()
         self.load_media_files()
+        self.theme_combo_box.setEditText(u'')
         self.theme_combo_box.setCurrentIndex(0)
         # it's a new song to preview is not possible
         self.preview_button.setVisible(False)
@@ -376,8 +377,15 @@
         if self.song.song_book_id != 0:
             book_name = self.manager.get_object(Book, self.song.song_book_id)
             find_and_set_in_combo_box(self.song_book_combo_box, unicode(book_name.name))
+        else:
+            self.song_book_combo_box.setEditText(u'')
+            self.song_book_combo_box.setCurrentIndex(0)
         if self.song.theme_name:
             find_and_set_in_combo_box(self.theme_combo_box, unicode(self.song.theme_name))
+        else:
+            # Clear the theme combo box in case it was previously set (bug #1212801)
+            self.theme_combo_box.setEditText(u'')
+            self.theme_combo_box.setCurrentIndex(0)
         self.copyright_edit.setText(self.song.copyright if self.song.copyright else u'')
         self.comments_edit.setPlainText(self.song.comments if self.song.comments else u'')
         self.ccli_number_edit.setText(self.song.ccli_number if self.song.ccli_number else u'')

=== added directory 'tests/functional/openlp_plugins/bibles'
=== added file 'tests/functional/openlp_plugins/bibles/__init__.py'
--- tests/functional/openlp_plugins/bibles/__init__.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/bibles/__init__.py	2013-08-15 19:58:41 +0000
@@ -0,0 +1,3 @@
+"""
+Tests for the Bibles plugin
+"""

=== added file 'tests/functional/openlp_plugins/bibles/test_lib.py'
--- tests/functional/openlp_plugins/bibles/test_lib.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/bibles/test_lib.py	2013-08-15 19:58:41 +0000
@@ -0,0 +1,59 @@
+"""
+This module contains tests for the lib submodule of the Bibles plugin.
+"""
+from unittest import TestCase
+
+from openlp.plugins.bibles.lib import SearchResults
+
+
+class TestLib(TestCase):
+    """
+    Test the functions in the :mod:`lib` module.
+    """
+    def search_results_creation_test(self):
+        """
+        Test the creation and construction of the SearchResults class
+        """
+        # GIVEN: A book, chapter and a verse list
+        book = u'Genesis'
+        chapter = 1
+        verse_list = {
+            1: u'In the beginning God created the heavens and the earth.',
+            2: u'The earth was without form and void, and darkness was over the face of the deep. And the Spirit of '
+               u'God was hovering over the face of the waters.'
+        }
+
+        # WHEN: We create the search results object
+        search_results = SearchResults(book, chapter, verse_list)
+
+        # THEN: It should have a book, a chapter and a verse list
+        self.assertIsNotNone(search_results, u'The search_results object should not be None')
+        self.assertEqual(search_results.book, book, u'The book should be "Genesis"')
+        self.assertEqual(search_results.chapter, chapter, u'The chapter should be 1')
+        self.assertDictEqual(search_results.verse_list, verse_list, u'The verse lists should be identical')
+
+    def search_results_has_verse_list_test(self):
+        """
+        Test that a SearchResults object with a valid verse list returns True when checking ``has_verse_list()``
+        """
+        # GIVEN: A valid SearchResults object with a proper verse list
+        search_results = SearchResults(u'Genesis', 1, {1: u'In the beginning God created the heavens and the earth.'})
+
+        # WHEN: We check that the SearchResults object has a verse list
+        has_verse_list = search_results.has_verse_list()
+
+        # THEN: It should be True
+        self.assertTrue(has_verse_list, u'The SearchResults object should have a verse list')
+
+    def search_results_has_no_verse_list_test(self):
+        """
+        Test that a SearchResults object with an empty verse list returns False when checking ``has_verse_list()``
+        """
+        # GIVEN: A valid SearchResults object with an empty verse list
+        search_results = SearchResults(u'Genesis', 1, {})
+
+        # WHEN: We check that the SearchResults object has a verse list
+        has_verse_list = search_results.has_verse_list()
+
+        # THEN: It should be False
+        self.assertFalse(has_verse_list, u'The SearchResults object should have a verse list')

=== modified file 'tests/functional/openlp_plugins/songs/__init__.py'
--- tests/functional/openlp_plugins/songs/__init__.py	2013-02-19 12:49:21 +0000
+++ tests/functional/openlp_plugins/songs/__init__.py	2013-08-15 19:58:41 +0000
@@ -0,0 +1,3 @@
+"""
+Tests for the Songs plugin
+"""


References