← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~sam92/openlp/bug-1369139 into lp:openlp

 

Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/bug-1369139 into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
  Tim Bentley (trb143)
Related bugs:
  Bug #1366198 in OpenLP: "Duplicate Song Finder displays blank "match" page"
  https://bugs.launchpad.net/openlp/+bug/1366198
  Bug #1369139 in OpenLP: "Search for authors broken"
  https://bugs.launchpad.net/openlp/+bug/1369139

For more details, see:
https://code.launchpad.net/~sam92/openlp/bug-1369139/+merge/234595

Fix author<->songs relation

Regression since rev. 2371

lp:~sam92/openlp/bug-1369139 (revision 2423)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/611/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/560/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/504/
[SUCCESS] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/463/
[SUCCESS] http://ci.openlp.org/job/Branch-04b-Windows_Interface_Tests/75/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/290/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/164/
-- 
https://code.launchpad.net/~sam92/openlp/bug-1369139/+merge/234595
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/lib/db.py'
--- openlp/plugins/songs/lib/db.py	2014-07-05 20:04:17 +0000
+++ openlp/plugins/songs/lib/db.py	2014-09-14 13:49:12 +0000
@@ -31,8 +31,6 @@
 the Songs plugin
 """
 
-import re
-
 from sqlalchemy import Column, ForeignKey, Table, types
 from sqlalchemy.orm import mapper, relation, reconstructor
 from sqlalchemy.sql.expression import func, text
@@ -329,7 +327,9 @@
         Column('topic_id', types.Integer(), ForeignKey('topics.id'), primary_key=True)
     )
 
-    mapper(Author, authors_table)
+    mapper(Author, authors_table, properties={
+        'songs': relation(Song, secondary=authors_songs_table, viewonly=True)
+    })
     mapper(AuthorSong, authors_songs_table, properties={
         'author': relation(Author)
     })
@@ -339,7 +339,8 @@
         # Use the authors_songs relation when you need access to the 'author_type' attribute
         # or when creating new relations
         'authors_songs': relation(AuthorSong, cascade="all, delete-orphan"),
-        'authors': relation(Author, secondary=authors_songs_table, viewonly=True),
+        # Use lazy='joined' to always load authors when the song is fetched from the database (bug 1366198)
+        'authors': relation(Author, secondary=authors_songs_table, viewonly=True, lazy='joined'),
         'book': relation(Book, backref='songs'),
         'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight),
         'topics': relation(Topic, backref='songs', secondary=songs_topics_table)

=== modified file 'tests/functional/openlp_core_lib/test_ui.py'
--- tests/functional/openlp_core_lib/test_ui.py	2014-09-07 22:17:20 +0000
+++ tests/functional/openlp_core_lib/test_ui.py	2014-09-14 13:49:12 +0000
@@ -195,9 +195,9 @@
             self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
                              'setIconVisibleInMenu should not have been called')
 
-    def create_checked_enabled_visible_action_test(self):
+    def create_checked_disabled_invisible_action_test(self):
         """
-        Test creating an action with the 'checked', 'enabled' and 'visible' properties.
+        Test that an invisible, disabled, checked action is created correctly
         """
         # GIVEN: A dialog
         dialog = QtGui.QDialog()
@@ -206,9 +206,22 @@
         action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)
 
         # THEN: These properties should be set
-        self.assertEqual(True, action.isChecked())
-        self.assertEqual(False, action.isEnabled())
-        self.assertEqual(False, action.isVisible())
+        self.assertTrue(action.isChecked(), 'The action should be checked')
+        self.assertFalse(action.isEnabled(), 'The action should be disabled')
+        self.assertFalse(action.isVisible(), 'The action should be invisble')
+
+    def create_action_separator_test(self):
+        """
+        Test creating an action as separator
+        """
+        # GIVEN: A dialog
+        dialog = QtGui.QDialog()
+
+        # WHEN: We create an action as a separator
+        action = create_action(dialog, 'my_action', separator=True)
+
+        # THEN: The action should be a separator
+        self.assertTrue(action.isSeparator(), 'The action should be a separator')
 
     def create_valign_selection_widgets_test(self):
         """


Follow ups