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
1=== modified file 'openlp/core/ui/slidecontroller.py'
2--- openlp/core/ui/slidecontroller.py 2017-01-22 20:01:53 +0000
3+++ openlp/core/ui/slidecontroller.py 2017-03-28 04:57:18 +0000
4@@ -909,7 +909,9 @@
5 Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
6 if old_item.is_media() and not self.service_item.is_media():
7 self.on_media_close()
8- Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
9+ if self.is_live:
10+ # This even is only registered for live
11+ Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
12
13 def on_slide_selected_index(self, message):
14 """
15
16=== modified file 'openlp/plugins/songs/lib/importers/openlp.py'
17--- openlp/plugins/songs/lib/importers/openlp.py 2017-03-09 05:36:11 +0000
18+++ openlp/plugins/songs/lib/importers/openlp.py 2017-03-28 04:57:18 +0000
19@@ -149,7 +149,12 @@
20 class_mapper(OldSongBookEntry)
21 except UnmappedClassError:
22 mapper(OldSongBookEntry, source_songs_songbooks_table, properties={'songbook': relation(OldBook)})
23- if has_authors_songs and 'author_type' in source_authors_songs_table.c.values():
24+ if has_authors_songs:
25+ try:
26+ class_mapper(OldAuthorSong)
27+ except UnmappedClassError:
28+ mapper(OldAuthorSong, source_authors_songs_table)
29+ if has_authors_songs and 'author_type' in source_authors_songs_table.c.keys():
30 has_author_type = True
31 else:
32 has_author_type = False
33@@ -190,11 +195,6 @@
34 class_mapper(OldTopic)
35 except UnmappedClassError:
36 mapper(OldTopic, source_topics_table)
37- if has_authors_songs:
38- try:
39- class_mapper(OldAuthorSong)
40- except UnmappedClassError:
41- mapper(OldAuthorSong, source_authors_songs_table)
42
43 source_songs = self.source_session.query(OldSong).all()
44 if self.import_wizard:
45
46=== modified file 'tests/functional/openlp_core/test_init.py'
47--- tests/functional/openlp_core/test_init.py 2017-03-01 18:24:27 +0000
48+++ tests/functional/openlp_core/test_init.py 2017-03-28 04:57:18 +0000
49@@ -24,6 +24,8 @@
50 from unittest import TestCase
51 from unittest.mock import MagicMock, patch
52
53+from PyQt5 import QtWidgets
54+
55 from openlp.core import OpenLP, parse_options
56
57
58@@ -156,3 +158,73 @@
59 assert result is False
60
61 del app
62+
63+ @patch('openlp.core.QtCore.QSharedMemory')
64+ def test_is_already_running_not_running(self, MockedSharedMemory):
65+ """
66+ Test the is_already_running() method when OpenLP is NOT running
67+ """
68+ # GIVEN: An OpenLP app and some mocks
69+ mocked_shared_memory = MagicMock()
70+ mocked_shared_memory.attach.return_value = False
71+ MockedSharedMemory.return_value = mocked_shared_memory
72+ app = OpenLP([])
73+
74+ # WHEN: is_already_running() is called
75+ result = app.is_already_running()
76+
77+ # THEN: The result should be false
78+ MockedSharedMemory.assert_called_once_with('OpenLP')
79+ mocked_shared_memory.attach.assert_called_once_with()
80+ mocked_shared_memory.create.assert_called_once_with(1)
81+ assert result is False
82+
83+ @patch('openlp.core.QtWidgets.QMessageBox.critical')
84+ @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
85+ @patch('openlp.core.QtCore.QSharedMemory')
86+ def test_is_already_running_is_running_continue(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
87+ """
88+ Test the is_already_running() method when OpenLP IS running and the user chooses to continue
89+ """
90+ # GIVEN: An OpenLP app and some mocks
91+ mocked_shared_memory = MagicMock()
92+ mocked_shared_memory.attach.return_value = True
93+ MockedSharedMemory.return_value = mocked_shared_memory
94+ MockedStandardButtons.return_value = 0
95+ mocked_critical.return_value = QtWidgets.QMessageBox.Yes
96+ app = OpenLP([])
97+
98+ # WHEN: is_already_running() is called
99+ result = app.is_already_running()
100+
101+ # THEN: The result should be false
102+ MockedSharedMemory.assert_called_once_with('OpenLP')
103+ mocked_shared_memory.attach.assert_called_once_with()
104+ MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
105+ mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
106+ assert result is False
107+
108+ @patch('openlp.core.QtWidgets.QMessageBox.critical')
109+ @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
110+ @patch('openlp.core.QtCore.QSharedMemory')
111+ def test_is_already_running_is_running_stop(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
112+ """
113+ Test the is_already_running() method when OpenLP IS running and the user chooses to stop
114+ """
115+ # GIVEN: An OpenLP app and some mocks
116+ mocked_shared_memory = MagicMock()
117+ mocked_shared_memory.attach.return_value = True
118+ MockedSharedMemory.return_value = mocked_shared_memory
119+ MockedStandardButtons.return_value = 0
120+ mocked_critical.return_value = QtWidgets.QMessageBox.No
121+ app = OpenLP([])
122+
123+ # WHEN: is_already_running() is called
124+ result = app.is_already_running()
125+
126+ # THEN: The result should be false
127+ MockedSharedMemory.assert_called_once_with('OpenLP')
128+ mocked_shared_memory.attach.assert_called_once_with()
129+ MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
130+ mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
131+ assert result is True
132
133=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
134--- tests/functional/openlp_core_ui/test_slidecontroller.py 2016-12-31 11:05:48 +0000
135+++ tests/functional/openlp_core_ui/test_slidecontroller.py 2017-03-28 04:57:18 +0000
136@@ -681,7 +681,7 @@
137 slide_controller._process_item(mocked_media_item, 0)
138
139 # THEN: Registry.execute should have been called to stop the presentation
140- self.assertEqual(3, mocked_execute.call_count, 'Execute should have been called 3 times')
141+ self.assertEqual(2, mocked_execute.call_count, 'Execute should have been called 2 times')
142 self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
143 'The presentation should have been stopped.')
144
145
146=== modified file 'tests/functional/openlp_plugins/songs/test_openlpimporter.py'
147--- tests/functional/openlp_plugins/songs/test_openlpimporter.py 2016-12-31 11:05:48 +0000
148+++ tests/functional/openlp_plugins/songs/test_openlpimporter.py 2017-03-28 04:57:18 +0000
149@@ -23,10 +23,10 @@
150 This module contains tests for the OpenLP song importer.
151 """
152 from unittest import TestCase
153+from unittest.mock import patch, MagicMock
154
155+from openlp.core.common import Registry
156 from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
157-from openlp.core.common import Registry
158-from tests.functional import patch, MagicMock
159
160
161 class TestOpenLPImport(TestCase):
162
163=== modified file 'tests/resources/opensongsongs/Amazing Grace.json'
164--- tests/resources/opensongsongs/Amazing Grace.json 2014-04-21 15:49:41 +0000
165+++ tests/resources/opensongsongs/Amazing Grace.json 2017-03-28 04:57:18 +0000
166@@ -39,4 +39,4 @@
167 "v5"
168 ]
169 ]
170-}
171\ No newline at end of file
172+}

Subscribers

People subscribed via source and target branches

to all changes: