Merge lp:~raoul-snyman/openlp/fix-author_type into lp:openlp

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 2730
Proposed branch: lp:~raoul-snyman/openlp/fix-author_type
Merge into: lp:openlp
Diff against target: 160 lines (+81/-11)
4 files modified
openlp/core/ui/slidecontroller.py (+2/-1)
openlp/plugins/songs/lib/importers/openlp.py (+6/-6)
tests/functional/openlp_core/test_init.py (+72/-3)
tests/functional/openlp_core_ui/test_slidecontroller.py (+1/-1)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/fix-author_type
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Tomas Groth Approve
Review via email: mp+321138@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) :
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 2016-12-31 11:01:36 +0000
3+++ openlp/core/ui/slidecontroller.py 2017-03-28 05:26:11 +0000
4@@ -921,7 +921,8 @@
5 Registry().execute('{name}_stop'.format(name=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_{item}_started'.format(item=self.type_prefix), [self.service_item])
9+ if self.is_live:
10+ Registry().execute('slidecontroller_{item}_started'.format(item=self.type_prefix), [self.service_item])
11
12 def on_slide_selected_index(self, message):
13 """
14
15=== modified file 'openlp/plugins/songs/lib/importers/openlp.py'
16--- openlp/plugins/songs/lib/importers/openlp.py 2017-03-23 04:43:13 +0000
17+++ openlp/plugins/songs/lib/importers/openlp.py 2017-03-28 05:26:11 +0000
18@@ -150,7 +150,12 @@
19 class_mapper(OldSongBookEntry)
20 except UnmappedClassError:
21 mapper(OldSongBookEntry, source_songs_songbooks_table, properties={'songbook': relation(OldBook)})
22- if has_authors_songs and 'author_type' in source_authors_songs_table.c.values():
23+ if has_authors_songs:
24+ try:
25+ class_mapper(OldAuthorSong)
26+ except UnmappedClassError:
27+ mapper(OldAuthorSong, source_authors_songs_table)
28+ if has_authors_songs and 'author_type' in source_authors_songs_table.c.keys():
29 has_author_type = True
30 else:
31 has_author_type = False
32@@ -191,11 +196,6 @@
33 class_mapper(OldTopic)
34 except UnmappedClassError:
35 mapper(OldTopic, source_topics_table)
36- if has_authors_songs:
37- try:
38- class_mapper(OldTopic)
39- except UnmappedClassError:
40- mapper(OldTopic, source_topics_table)
41
42 source_songs = self.source_session.query(OldSong).all()
43 if self.import_wizard:
44
45=== modified file 'tests/functional/openlp_core/test_init.py'
46--- tests/functional/openlp_core/test_init.py 2017-03-10 23:20:44 +0000
47+++ tests/functional/openlp_core/test_init.py 2017-03-28 05:26:11 +0000
48@@ -19,11 +19,12 @@
49 # with this program; if not, write to the Free Software Foundation, Inc., 59 #
50 # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
51 ###############################################################################
52-
53 import sys
54 from unittest import TestCase, skip
55 from unittest.mock import MagicMock, patch
56
57+from PyQt5 import QtWidgets
58+
59 from openlp.core import OpenLP, parse_options
60
61
62@@ -131,11 +132,11 @@
63 self.assertEquals(args.rargs, 'dummy_temp', 'The service file should not be blank')
64
65
66+@skip('Figure out why this is causing a segfault')
67 class TestOpenLP(TestCase):
68 """
69 Test the OpenLP app class
70 """
71- @skip('Figure out why this is causing a segfault')
72 @patch('openlp.core.QtWidgets.QApplication.exec')
73 def test_exec(self, mocked_exec):
74 """
75@@ -155,4 +156,72 @@
76 app.shared_memory.detach.assert_called_once_with()
77 assert result is False
78
79- del app
80+ @patch('openlp.core.QtCore.QSharedMemory')
81+ def test_is_already_running_not_running(self, MockedSharedMemory):
82+ """
83+ Test the is_already_running() method when OpenLP is NOT running
84+ """
85+ # GIVEN: An OpenLP app and some mocks
86+ mocked_shared_memory = MagicMock()
87+ mocked_shared_memory.attach.return_value = False
88+ MockedSharedMemory.return_value = mocked_shared_memory
89+ app = OpenLP([])
90+
91+ # WHEN: is_already_running() is called
92+ result = app.is_already_running()
93+
94+ # THEN: The result should be false
95+ MockedSharedMemory.assert_called_once_with('OpenLP')
96+ mocked_shared_memory.attach.assert_called_once_with()
97+ mocked_shared_memory.create.assert_called_once_with(1)
98+ assert result is False
99+
100+ @patch('openlp.core.QtWidgets.QMessageBox.critical')
101+ @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
102+ @patch('openlp.core.QtCore.QSharedMemory')
103+ def test_is_already_running_is_running_continue(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
104+ """
105+ Test the is_already_running() method when OpenLP IS running and the user chooses to continue
106+ """
107+ # GIVEN: An OpenLP app and some mocks
108+ mocked_shared_memory = MagicMock()
109+ mocked_shared_memory.attach.return_value = True
110+ MockedSharedMemory.return_value = mocked_shared_memory
111+ MockedStandardButtons.return_value = 0
112+ mocked_critical.return_value = QtWidgets.QMessageBox.Yes
113+ app = OpenLP([])
114+
115+ # WHEN: is_already_running() is called
116+ result = app.is_already_running()
117+
118+ # THEN: The result should be false
119+ MockedSharedMemory.assert_called_once_with('OpenLP')
120+ mocked_shared_memory.attach.assert_called_once_with()
121+ MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
122+ mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
123+ assert result is False
124+
125+ @patch('openlp.core.QtWidgets.QMessageBox.critical')
126+ @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
127+ @patch('openlp.core.QtCore.QSharedMemory')
128+ def test_is_already_running_is_running_stop(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
129+ """
130+ Test the is_already_running() method when OpenLP IS running and the user chooses to stop
131+ """
132+ # GIVEN: An OpenLP app and some mocks
133+ mocked_shared_memory = MagicMock()
134+ mocked_shared_memory.attach.return_value = True
135+ MockedSharedMemory.return_value = mocked_shared_memory
136+ MockedStandardButtons.return_value = 0
137+ mocked_critical.return_value = QtWidgets.QMessageBox.No
138+ app = OpenLP([])
139+
140+ # WHEN: is_already_running() is called
141+ result = app.is_already_running()
142+
143+ # THEN: The result should be false
144+ MockedSharedMemory.assert_called_once_with('OpenLP')
145+ mocked_shared_memory.attach.assert_called_once_with()
146+ MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
147+ mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
148+ assert result is True
149
150=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
151--- tests/functional/openlp_core_ui/test_slidecontroller.py 2016-12-31 11:01:36 +0000
152+++ tests/functional/openlp_core_ui/test_slidecontroller.py 2017-03-28 05:26:11 +0000
153@@ -658,7 +658,7 @@
154 slide_controller._process_item(mocked_media_item, 0)
155
156 # THEN: Registry.execute should have been called to stop the presentation
157- self.assertEqual(3, mocked_execute.call_count, 'Execute should have been called 3 times')
158+ self.assertEqual(2, mocked_execute.call_count, 'Execute should have been called 2 times')
159 self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
160 'The presentation should have been stopped.')
161