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

Proposed by Tim Bentley
Status: Merged
Merged at revision: 2606
Proposed branch: lp:~trb143/openlp/broken_search
Merge into: lp:openlp
Diff against target: 114 lines (+87/-2)
3 files modified
openlp/plugins/remotes/lib/httprouter.py (+1/-1)
tests/functional/openlp_plugins/media/test_mediaitem.py (+86/-0)
tests/functional/openlp_plugins/remotes/test_router.py (+0/-1)
To merge this branch: bzr merge lp:~trb143/openlp/broken_search
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+282232@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/remotes/lib/httprouter.py'
2--- openlp/plugins/remotes/lib/httprouter.py 2015-12-31 22:46:06 +0000
3+++ openlp/plugins/remotes/lib/httprouter.py 2016-01-11 22:01:57 +0000
4@@ -621,7 +621,7 @@
5 event = getattr(self.service_manager, 'servicemanager_%s_item' % action)
6 if self.request_data:
7 try:
8- data = json.loads(self.request_data)['request']['id']
9+ data = int(json.loads(self.request_data)['request']['id'])
10 except KeyError:
11 return self.do_http_error()
12 event.emit(data)
13
14=== added file 'tests/functional/openlp_plugins/media/test_mediaitem.py'
15--- tests/functional/openlp_plugins/media/test_mediaitem.py 1970-01-01 00:00:00 +0000
16+++ tests/functional/openlp_plugins/media/test_mediaitem.py 2016-01-11 22:01:57 +0000
17@@ -0,0 +1,86 @@
18+# -*- coding: utf-8 -*-
19+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
20+
21+###############################################################################
22+# OpenLP - Open Source Lyrics Projection #
23+# --------------------------------------------------------------------------- #
24+# Copyright (c) 2008-2016 OpenLP Developers #
25+# --------------------------------------------------------------------------- #
26+# This program is free software; you can redistribute it and/or modify it #
27+# under the terms of the GNU General Public License as published by the Free #
28+# Software Foundation; version 2 of the License. #
29+# #
30+# This program is distributed in the hope that it will be useful, but WITHOUT #
31+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
32+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
33+# more details. #
34+# #
35+# You should have received a copy of the GNU General Public License along #
36+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
37+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
38+###############################################################################
39+"""
40+Test the media plugin
41+"""
42+from unittest import TestCase
43+
44+from openlp.core import Registry, Settings
45+from openlp.plugins.media.mediaplugin import MediaPlugin
46+from openlp.plugins.media.lib.mediaitem import MediaMediaItem
47+from openlp.core.ui.media.mediacontroller import MediaController
48+
49+from PyQt5 import QtCore
50+
51+from tests.functional import MagicMock, patch
52+from tests.helpers.testmixin import TestMixin
53+
54+__default_settings__ = {
55+ 'media/media auto start': QtCore.Qt.Unchecked,
56+ 'media/media files': []
57+}
58+
59+
60+class MediaItemTest(TestCase, TestMixin):
61+ """
62+ Test the media item for Media
63+ """
64+
65+ def setUp(self):
66+ """
67+ Set up the components need for all tests.
68+ """
69+ with patch('openlp.plugins.media.lib.mediaitem.MediaManagerItem.__init__'),\
70+ patch('openlp.plugins.media.lib.mediaitem.MediaMediaItem.setup'):
71+ self.media_item = MediaMediaItem(None, MagicMock())
72+ self.media_item.settings_section = 'media'
73+ self.setup_application()
74+ self.build_settings()
75+ Settings().extend_default_settings(__default_settings__)
76+
77+ def tearDown(self):
78+ """
79+ Clean up after the tests
80+ """
81+ self.destroy_settings()
82+
83+ def test_search_found(self):
84+ """
85+ Media Remote Search Successful find
86+ """
87+ # GIVEN: The Mediaitem set up a list of media
88+ Settings().setValue(self.media_item.settings_section + '/media files', ['test.mp3', 'test.mp4'])
89+ # WHEN: Retrieving the test file
90+ result = self.media_item.search('test.mp4', False)
91+ # THEN: a file should be found
92+ self.assertEqual(result, [['test.mp4', 'test.mp4']], 'The result file contain the file name')
93+
94+ def test_search_not_found(self):
95+ """
96+ Media Remote Search not find
97+ """
98+ # GIVEN: The Mediaitem set up a list of media
99+ Settings().setValue(self.media_item.settings_section + '/media files', ['test.mp3', 'test.mp4'])
100+ # WHEN: Retrieving the test file
101+ result = self.media_item.search('test.mpx', False)
102+ # THEN: a file should be found
103+ self.assertEqual(result, [], 'The result file should be empty')
104
105=== modified file 'tests/functional/openlp_plugins/remotes/test_router.py'
106--- tests/functional/openlp_plugins/remotes/test_router.py 2015-12-31 22:46:06 +0000
107+++ tests/functional/openlp_plugins/remotes/test_router.py 2016-01-11 22:01:57 +0000
108@@ -29,7 +29,6 @@
109 from openlp.core.common import Settings, Registry
110 from openlp.core.ui import ServiceManager
111 from openlp.plugins.remotes.lib.httpserver import HttpRouter
112-from urllib.parse import urlparse
113 from tests.functional import MagicMock, patch, mock_open
114 from tests.helpers.testmixin import TestMixin
115