← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/broken_search into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/broken_search into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~trb143/openlp/broken_search/+merge/281689

Remote search is broken due to the change for alternate titles added for songs.
This fixes it.

CI does not work !
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/broken_search into lp:openlp.
=== modified file 'openlp/plugins/remotes/html/openlp.js'
--- openlp/plugins/remotes/html/openlp.js	2015-12-31 22:46:06 +0000
+++ openlp/plugins/remotes/html/openlp.js	2016-01-05 19:41:13 +0000
@@ -272,7 +272,7 @@
                 value[0] = OpenLP.escapeString(value[0])
               }
               var txt = "";
-              if (value[2].length > 0) {
+              if (value.length > 2) {
                 txt = value[1] + " ( " + value[2] + " )";
               } else {
                 txt = value[1];

=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
--- tests/functional/openlp_plugins/songs/test_mediaitem.py	2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_plugins/songs/test_mediaitem.py	2016-01-05 19:41:13 +0000
@@ -257,3 +257,22 @@
 
         # THEN: They should not match
         self.assertFalse(result, "Authors should not match")
+
+    def build_remote_search_test(self):
+        """
+        Test results for the remote search api
+        """
+        # GIVEN: A Song and a search a JSON array should be returned.
+        mock_song = MagicMock()
+        mock_song.id = 123
+        mock_song.title = 'My Song'
+        mock_song.search_title = 'My Song'
+        mock_song.alternate_title = 'My alternative'
+        self.media_item.search_entire = MagicMock()
+        self.media_item.search_entire.return_value = [mock_song]
+
+        # WHEN: I process a search
+        search_results = self.media_item.search('My Song', False)
+
+        # THEN: The correct formatted results are returned
+        self.assertEqual(search_results, [[123, 'My Song', 'My alternative']])


Follow ups