Merge lp:~raoul-snyman/openlp/fix-author-type-2.4 into lp:openlp/2.4

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 2680
Proposed branch: lp:~raoul-snyman/openlp/fix-author-type-2.4
Merge into: lp:openlp/2.4
Diff against target: 172 lines (+85/-11)
6 files modified
openlp/core/ui/slidecontroller.py (+3/-1)
openlp/plugins/songs/lib/importers/openlp.py (+6/-6)
tests/functional/openlp_core/test_init.py (+72/-0)
tests/functional/openlp_core_ui/test_slidecontroller.py (+1/-1)
tests/functional/openlp_plugins/songs/test_openlpimporter.py (+2/-2)
tests/resources/opensongsongs/Amazing Grace.json (+1/-1)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/fix-author-type-2.4
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Tomas Groth Approve
Review via email: mp+321137@code.launchpad.net

Commit message

Fix the author_type import properly

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote :

I'm gonna trust you on this one...

review: Approve
Revision history for this message
Tim Bentley (trb143) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2017-01-22 20:01:53 +0000
+++ openlp/core/ui/slidecontroller.py 2017-03-28 04:57:18 +0000
@@ -909,7 +909,9 @@
909 Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])909 Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
910 if old_item.is_media() and not self.service_item.is_media():910 if old_item.is_media() and not self.service_item.is_media():
911 self.on_media_close()911 self.on_media_close()
912 Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])912 if self.is_live:
913 # This even is only registered for live
914 Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
913915
914 def on_slide_selected_index(self, message):916 def on_slide_selected_index(self, message):
915 """917 """
916918
=== modified file 'openlp/plugins/songs/lib/importers/openlp.py'
--- openlp/plugins/songs/lib/importers/openlp.py 2017-03-09 05:36:11 +0000
+++ openlp/plugins/songs/lib/importers/openlp.py 2017-03-28 04:57:18 +0000
@@ -149,7 +149,12 @@
149 class_mapper(OldSongBookEntry)149 class_mapper(OldSongBookEntry)
150 except UnmappedClassError:150 except UnmappedClassError:
151 mapper(OldSongBookEntry, source_songs_songbooks_table, properties={'songbook': relation(OldBook)})151 mapper(OldSongBookEntry, source_songs_songbooks_table, properties={'songbook': relation(OldBook)})
152 if has_authors_songs and 'author_type' in source_authors_songs_table.c.values():152 if has_authors_songs:
153 try:
154 class_mapper(OldAuthorSong)
155 except UnmappedClassError:
156 mapper(OldAuthorSong, source_authors_songs_table)
157 if has_authors_songs and 'author_type' in source_authors_songs_table.c.keys():
153 has_author_type = True158 has_author_type = True
154 else:159 else:
155 has_author_type = False160 has_author_type = False
@@ -190,11 +195,6 @@
190 class_mapper(OldTopic)195 class_mapper(OldTopic)
191 except UnmappedClassError:196 except UnmappedClassError:
192 mapper(OldTopic, source_topics_table)197 mapper(OldTopic, source_topics_table)
193 if has_authors_songs:
194 try:
195 class_mapper(OldAuthorSong)
196 except UnmappedClassError:
197 mapper(OldAuthorSong, source_authors_songs_table)
198198
199 source_songs = self.source_session.query(OldSong).all()199 source_songs = self.source_session.query(OldSong).all()
200 if self.import_wizard:200 if self.import_wizard:
201201
=== modified file 'tests/functional/openlp_core/test_init.py'
--- tests/functional/openlp_core/test_init.py 2017-03-01 18:24:27 +0000
+++ tests/functional/openlp_core/test_init.py 2017-03-28 04:57:18 +0000
@@ -24,6 +24,8 @@
24from unittest import TestCase24from unittest import TestCase
25from unittest.mock import MagicMock, patch25from unittest.mock import MagicMock, patch
2626
27from PyQt5 import QtWidgets
28
27from openlp.core import OpenLP, parse_options29from openlp.core import OpenLP, parse_options
2830
2931
@@ -156,3 +158,73 @@
156 assert result is False158 assert result is False
157159
158 del app160 del app
161
162 @patch('openlp.core.QtCore.QSharedMemory')
163 def test_is_already_running_not_running(self, MockedSharedMemory):
164 """
165 Test the is_already_running() method when OpenLP is NOT running
166 """
167 # GIVEN: An OpenLP app and some mocks
168 mocked_shared_memory = MagicMock()
169 mocked_shared_memory.attach.return_value = False
170 MockedSharedMemory.return_value = mocked_shared_memory
171 app = OpenLP([])
172
173 # WHEN: is_already_running() is called
174 result = app.is_already_running()
175
176 # THEN: The result should be false
177 MockedSharedMemory.assert_called_once_with('OpenLP')
178 mocked_shared_memory.attach.assert_called_once_with()
179 mocked_shared_memory.create.assert_called_once_with(1)
180 assert result is False
181
182 @patch('openlp.core.QtWidgets.QMessageBox.critical')
183 @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
184 @patch('openlp.core.QtCore.QSharedMemory')
185 def test_is_already_running_is_running_continue(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
186 """
187 Test the is_already_running() method when OpenLP IS running and the user chooses to continue
188 """
189 # GIVEN: An OpenLP app and some mocks
190 mocked_shared_memory = MagicMock()
191 mocked_shared_memory.attach.return_value = True
192 MockedSharedMemory.return_value = mocked_shared_memory
193 MockedStandardButtons.return_value = 0
194 mocked_critical.return_value = QtWidgets.QMessageBox.Yes
195 app = OpenLP([])
196
197 # WHEN: is_already_running() is called
198 result = app.is_already_running()
199
200 # THEN: The result should be false
201 MockedSharedMemory.assert_called_once_with('OpenLP')
202 mocked_shared_memory.attach.assert_called_once_with()
203 MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
204 mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
205 assert result is False
206
207 @patch('openlp.core.QtWidgets.QMessageBox.critical')
208 @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
209 @patch('openlp.core.QtCore.QSharedMemory')
210 def test_is_already_running_is_running_stop(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
211 """
212 Test the is_already_running() method when OpenLP IS running and the user chooses to stop
213 """
214 # GIVEN: An OpenLP app and some mocks
215 mocked_shared_memory = MagicMock()
216 mocked_shared_memory.attach.return_value = True
217 MockedSharedMemory.return_value = mocked_shared_memory
218 MockedStandardButtons.return_value = 0
219 mocked_critical.return_value = QtWidgets.QMessageBox.No
220 app = OpenLP([])
221
222 # WHEN: is_already_running() is called
223 result = app.is_already_running()
224
225 # THEN: The result should be false
226 MockedSharedMemory.assert_called_once_with('OpenLP')
227 mocked_shared_memory.attach.assert_called_once_with()
228 MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
229 mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
230 assert result is True
159231
=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
--- tests/functional/openlp_core_ui/test_slidecontroller.py 2016-12-31 11:05:48 +0000
+++ tests/functional/openlp_core_ui/test_slidecontroller.py 2017-03-28 04:57:18 +0000
@@ -681,7 +681,7 @@
681 slide_controller._process_item(mocked_media_item, 0)681 slide_controller._process_item(mocked_media_item, 0)
682682
683 # THEN: Registry.execute should have been called to stop the presentation683 # THEN: Registry.execute should have been called to stop the presentation
684 self.assertEqual(3, mocked_execute.call_count, 'Execute should have been called 3 times')684 self.assertEqual(2, mocked_execute.call_count, 'Execute should have been called 2 times')
685 self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],685 self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
686 'The presentation should have been stopped.')686 'The presentation should have been stopped.')
687687
688688
=== modified file 'tests/functional/openlp_plugins/songs/test_openlpimporter.py'
--- tests/functional/openlp_plugins/songs/test_openlpimporter.py 2016-12-31 11:05:48 +0000
+++ tests/functional/openlp_plugins/songs/test_openlpimporter.py 2017-03-28 04:57:18 +0000
@@ -23,10 +23,10 @@
23This module contains tests for the OpenLP song importer.23This module contains tests for the OpenLP song importer.
24"""24"""
25from unittest import TestCase25from unittest import TestCase
26from unittest.mock import patch, MagicMock
2627
28from openlp.core.common import Registry
27from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport29from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
28from openlp.core.common import Registry
29from tests.functional import patch, MagicMock
3030
3131
32class TestOpenLPImport(TestCase):32class TestOpenLPImport(TestCase):
3333
=== modified file 'tests/resources/opensongsongs/Amazing Grace.json'
--- tests/resources/opensongsongs/Amazing Grace.json 2014-04-21 15:49:41 +0000
+++ tests/resources/opensongsongs/Amazing Grace.json 2017-03-28 04:57:18 +0000
@@ -39,4 +39,4 @@
39 "v5"39 "v5"
40 ]40 ]
41 ]41 ]
42}
43\ No newline at end of file42\ No newline at end of file
43}

Subscribers

People subscribed via source and target branches

to all changes: