← Back to team overview

openlp-core team mailing list archive

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

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/fix-author-type-2.4 into lp:openlp/2.4.

Commit message:
Fix the author_type import properly

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/fix-author-type-2.4/+merge/321137

Fix the author_type import properly

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/fix-author-type-2.4 (revision 2681)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1947/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1858/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1799/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1525/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/1115/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/1183/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/1051/
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/fix-author-type-2.4 into lp:openlp/2.4.
=== 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 @@
                 Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
             if old_item.is_media() and not self.service_item.is_media():
                 self.on_media_close()
-        Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
+        if self.is_live:
+            # This even is only registered for live
+            Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
 
     def on_slide_selected_index(self, message):
         """

=== 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 @@
                 class_mapper(OldSongBookEntry)
             except UnmappedClassError:
                 mapper(OldSongBookEntry, source_songs_songbooks_table, properties={'songbook': relation(OldBook)})
-        if has_authors_songs and 'author_type' in source_authors_songs_table.c.values():
+        if has_authors_songs:
+            try:
+                class_mapper(OldAuthorSong)
+            except UnmappedClassError:
+                mapper(OldAuthorSong, source_authors_songs_table)
+        if has_authors_songs and 'author_type' in source_authors_songs_table.c.keys():
             has_author_type = True
         else:
             has_author_type = False
@@ -190,11 +195,6 @@
             class_mapper(OldTopic)
         except UnmappedClassError:
             mapper(OldTopic, source_topics_table)
-        if has_authors_songs:
-            try:
-                class_mapper(OldAuthorSong)
-            except UnmappedClassError:
-                mapper(OldAuthorSong, source_authors_songs_table)
 
         source_songs = self.source_session.query(OldSong).all()
         if self.import_wizard:

=== 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 @@
 from unittest import TestCase
 from unittest.mock import MagicMock, patch
 
+from PyQt5 import QtWidgets
+
 from openlp.core import OpenLP, parse_options
 
 
@@ -156,3 +158,73 @@
         assert result is False
 
         del app
+
+    @patch('openlp.core.QtCore.QSharedMemory')
+    def test_is_already_running_not_running(self, MockedSharedMemory):
+        """
+        Test the is_already_running() method when OpenLP is NOT running
+        """
+        # GIVEN: An OpenLP app and some mocks
+        mocked_shared_memory = MagicMock()
+        mocked_shared_memory.attach.return_value = False
+        MockedSharedMemory.return_value = mocked_shared_memory
+        app = OpenLP([])
+
+        # WHEN: is_already_running() is called
+        result = app.is_already_running()
+
+        # THEN: The result should be false
+        MockedSharedMemory.assert_called_once_with('OpenLP')
+        mocked_shared_memory.attach.assert_called_once_with()
+        mocked_shared_memory.create.assert_called_once_with(1)
+        assert result is False
+
+    @patch('openlp.core.QtWidgets.QMessageBox.critical')
+    @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
+    @patch('openlp.core.QtCore.QSharedMemory')
+    def test_is_already_running_is_running_continue(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
+        """
+        Test the is_already_running() method when OpenLP IS running and the user chooses to continue
+        """
+        # GIVEN: An OpenLP app and some mocks
+        mocked_shared_memory = MagicMock()
+        mocked_shared_memory.attach.return_value = True
+        MockedSharedMemory.return_value = mocked_shared_memory
+        MockedStandardButtons.return_value = 0
+        mocked_critical.return_value = QtWidgets.QMessageBox.Yes
+        app = OpenLP([])
+
+        # WHEN: is_already_running() is called
+        result = app.is_already_running()
+
+        # THEN: The result should be false
+        MockedSharedMemory.assert_called_once_with('OpenLP')
+        mocked_shared_memory.attach.assert_called_once_with()
+        MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
+        mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
+        assert result is False
+
+    @patch('openlp.core.QtWidgets.QMessageBox.critical')
+    @patch('openlp.core.QtWidgets.QMessageBox.StandardButtons')
+    @patch('openlp.core.QtCore.QSharedMemory')
+    def test_is_already_running_is_running_stop(self, MockedSharedMemory, MockedStandardButtons, mocked_critical):
+        """
+        Test the is_already_running() method when OpenLP IS running and the user chooses to stop
+        """
+        # GIVEN: An OpenLP app and some mocks
+        mocked_shared_memory = MagicMock()
+        mocked_shared_memory.attach.return_value = True
+        MockedSharedMemory.return_value = mocked_shared_memory
+        MockedStandardButtons.return_value = 0
+        mocked_critical.return_value = QtWidgets.QMessageBox.No
+        app = OpenLP([])
+
+        # WHEN: is_already_running() is called
+        result = app.is_already_running()
+
+        # THEN: The result should be false
+        MockedSharedMemory.assert_called_once_with('OpenLP')
+        mocked_shared_memory.attach.assert_called_once_with()
+        MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
+        mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
+        assert result is True

=== 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 @@
         slide_controller._process_item(mocked_media_item, 0)
 
         # THEN: Registry.execute should have been called to stop the presentation
-        self.assertEqual(3, mocked_execute.call_count, 'Execute should have been called 3 times')
+        self.assertEqual(2, mocked_execute.call_count, 'Execute should have been called 2 times')
         self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
                          'The presentation should have been stopped.')
 

=== 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 @@
 This module contains tests for the OpenLP song importer.
 """
 from unittest import TestCase
+from unittest.mock import patch, MagicMock
 
+from openlp.core.common import Registry
 from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
-from openlp.core.common import Registry
-from tests.functional import patch, MagicMock
 
 
 class TestOpenLPImport(TestCase):

=== 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 @@
             "v5"
         ]
     ]
-}
\ No newline at end of file
+}


Follow ups