← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/android-bug into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/android-bug into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~trb143/openlp/android-bug/+merge/260070

lp:~trb143/openlp/android-bug (revision 2539)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/1023/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/946/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/888/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/775/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/373/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/505/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/376/

Started out as a one line fix!
Added to basic tests.
Cleanup up some tests to match style..

Then fixed a broken Jenkins script
Then fixed a load of broken tests 
Then fixed some spelling errors.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/android-bug into lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2015-03-18 22:02:51 +0000
+++ openlp/core/ui/slidecontroller.py	2015-05-25 20:14:58 +0000
@@ -824,6 +824,8 @@
         """
         self.on_stop_loop()
         old_item = self.service_item
+        # rest to allow the remote pick up verse 1 if large imaged
+        self.selected_row = 0
         # take a copy not a link to the servicemanager copy.
         self.service_item = copy.copy(service_item)
         if old_item and self.is_live and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
@@ -1417,11 +1419,11 @@
 
 class PreviewController(RegistryMixin, OpenLPMixin, SlideController):
     """
-    Set up the Live Controller.
+    Set up the Preview Controller.
     """
     def __init__(self, parent):
         """
-        Set up the general Controller.
+        Set up the base Controller as a preview.
         """
         super(PreviewController, self).__init__(parent)
         self.split = 0
@@ -1441,7 +1443,7 @@
     """
     def __init__(self, parent):
         """
-        Set up the general Controller.
+        Set up the base Controller as a live.
         """
         super(LiveController, self).__init__(parent)
         self.is_live = True

=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py	2015-02-23 17:40:56 +0000
+++ openlp/plugins/songs/forms/editverseform.py	2015-05-25 20:14:58 +0000
@@ -43,6 +43,7 @@
         """
         super(EditVerseForm, self).__init__(parent)
         self.setupUi(self)
+        self.has_single_verse = False
         self.insert_button.clicked.connect(self.on_insert_button_clicked)
         self.split_button.clicked.connect(self.on_split_button_clicked)
         self.verse_text_edit.cursorPositionChanged.connect(self.on_cursor_position_changed)

=== modified file 'scripts/jenkins_script.py'
--- scripts/jenkins_script.py	2015-03-02 19:18:14 +0000
+++ scripts/jenkins_script.py	2015-05-25 20:14:58 +0000
@@ -91,7 +91,7 @@
         """
         self.token = token
         self.repo_name = get_repo_name()
-        self.jenkins_instance = Jenkins(JENKINS_URL, verify=False)
+        self.jenkins_instance = Jenkins(JENKINS_URL)
 
     def trigger_build(self):
         """

=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
--- tests/functional/openlp_core_ui/test_slidecontroller.py	2015-01-29 20:57:02 +0000
+++ tests/functional/openlp_core_ui/test_slidecontroller.py	2015-05-25 20:14:58 +0000
@@ -27,7 +27,7 @@
 from unittest import TestCase
 from openlp.core import Registry
 from openlp.core.lib import ServiceItemAction
-from openlp.core.ui import SlideController
+from openlp.core.ui import SlideController, LiveController, PreviewController
 from openlp.core.ui.slidecontroller import InfoLabel, WIDE_MENU, NON_TEXT_MENU
 
 from tests.functional import MagicMock, patch
@@ -84,24 +84,24 @@
         # THEN: then call set up the toolbar to blank the display screen.
         toolbar.set_widget_visible.assert_called_with(NON_TEXT_MENU, True)
 
-    def receive_spin_delay_test(self):
+    @patch('openlp.core.ui.slidecontroller.Settings')
+    def receive_spin_delay_test(self, MockedSettings):
         """
         Test that the spin box is updated accordingly after a call to receive_spin_delay()
         """
-        with patch('openlp.core.ui.slidecontroller.Settings') as MockedSettings:
-            # GIVEN: A new SlideController instance.
-            mocked_value = MagicMock(return_value=1)
-            MockedSettings.return_value = MagicMock(value=mocked_value)
-            mocked_delay_spin_box = MagicMock()
-            slide_controller = SlideController(None)
-            slide_controller.delay_spin_box = mocked_delay_spin_box
-
-            # WHEN: The receive_spin_delay() method is called
-            slide_controller.receive_spin_delay()
-
-            # THEN: The Settings()value() and delay_spin_box.setValue() methods should have been called correctly
-            mocked_value.assert_called_with('core/loop delay')
-            mocked_delay_spin_box.setValue.assert_called_with(1)
+        # GIVEN: A new SlideController instance.
+        mocked_value = MagicMock(return_value=1)
+        MockedSettings.return_value = MagicMock(value=mocked_value)
+        mocked_delay_spin_box = MagicMock()
+        slide_controller = SlideController(None)
+        slide_controller.delay_spin_box = mocked_delay_spin_box
+
+        # WHEN: The receive_spin_delay() method is called
+        slide_controller.receive_spin_delay()
+
+        # THEN: The Settings()value() and delay_spin_box.setValue() methods should have been called correctly
+        mocked_value.assert_called_with('core/loop delay')
+        mocked_delay_spin_box.setValue.assert_called_with(1)
 
     def toggle_display_blank_test(self):
         """
@@ -267,25 +267,25 @@
         mocked_keypress_queue.append.assert_called_once_with(ServiceItemAction.Next)
         mocked_process_queue.assert_called_once_with()
 
-    def update_slide_limits_test(self):
+    @patch('openlp.core.ui.slidecontroller.Settings')
+    def update_slide_limits_test(self, MockedSettings):
         """
         Test that calling the update_slide_limits() method updates the slide limits
         """
         # GIVEN: A mocked out Settings object, a new SlideController and a mocked out main_window
-        with patch('openlp.core.ui.slidecontroller.Settings') as MockedSettings:
-            mocked_value = MagicMock(return_value=10)
-            MockedSettings.return_value = MagicMock(value=mocked_value)
-            mocked_main_window = MagicMock(advanced_settings_section='advanced')
-            Registry.create()
-            Registry().register('main_window', mocked_main_window)
-            slide_controller = SlideController(None)
-
-            # WHEN: update_slide_limits() is called
-            slide_controller.update_slide_limits()
-
-            # THEN: The value of slide_limits should be 10
-            mocked_value.assert_called_once_with('advanced/slide limits')
-            self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10')
+        mocked_value = MagicMock(return_value=10)
+        MockedSettings.return_value = MagicMock(value=mocked_value)
+        mocked_main_window = MagicMock(advanced_settings_section='advanced')
+        Registry.create()
+        Registry().register('main_window', mocked_main_window)
+        slide_controller = SlideController(None)
+
+        # WHEN: update_slide_limits() is called
+        slide_controller.update_slide_limits()
+
+        # THEN: The value of slide_limits should be 10
+        mocked_value.assert_called_once_with('advanced/slide limits')
+        self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10')
 
     def enable_tool_bar_live_test(self):
         """
@@ -522,7 +522,8 @@
         # THEN: It should have exited early
         self.assertEqual(0, mocked_item.is_command.call_count, 'The service item should have not been called')
 
-    def on_slide_selected_index_service_item_command_test(self):
+    @patch.object(Registry, 'execute')
+    def on_slide_selected_index_service_item_command_test(self, mocked_execute):
         """
         Test that when there is a command service item, the command is executed
         """
@@ -533,17 +534,16 @@
         mocked_update_preview = MagicMock()
         mocked_preview_widget = MagicMock()
         mocked_slide_selected = MagicMock()
-        with patch.object(Registry, 'execute') as mocked_execute:
-            Registry.create()
-            slide_controller = SlideController(None)
-            slide_controller.service_item = mocked_item
-            slide_controller.update_preview = mocked_update_preview
-            slide_controller.preview_widget = mocked_preview_widget
-            slide_controller.slide_selected = mocked_slide_selected
-            slide_controller.is_live = True
+        Registry.create()
+        slide_controller = SlideController(None)
+        slide_controller.service_item = mocked_item
+        slide_controller.update_preview = mocked_update_preview
+        slide_controller.preview_widget = mocked_preview_widget
+        slide_controller.slide_selected = mocked_slide_selected
+        slide_controller.is_live = True
 
-            # WHEN: The method is called
-            slide_controller.on_slide_selected_index([9])
+        # WHEN: The method is called
+        slide_controller.on_slide_selected_index([9])
 
         # THEN: It should have sent a notification
         mocked_item.is_command.assert_called_once_with()
@@ -552,7 +552,8 @@
         self.assertEqual(0, mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called')
         self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called')
 
-    def on_slide_selected_index_service_item_not_command_test(self):
+    @patch.object(Registry, 'execute')
+    def on_slide_selected_index_service_item_not_command_test(self, mocked_execute):
         """
         Test that when there is a service item but it's not a command, the preview widget is updated
         """
@@ -563,16 +564,15 @@
         mocked_update_preview = MagicMock()
         mocked_preview_widget = MagicMock()
         mocked_slide_selected = MagicMock()
-        with patch.object(Registry, 'execute') as mocked_execute:
-            Registry.create()
-            slide_controller = SlideController(None)
-            slide_controller.service_item = mocked_item
-            slide_controller.update_preview = mocked_update_preview
-            slide_controller.preview_widget = mocked_preview_widget
-            slide_controller.slide_selected = mocked_slide_selected
+        Registry.create()
+        slide_controller = SlideController(None)
+        slide_controller.service_item = mocked_item
+        slide_controller.update_preview = mocked_update_preview
+        slide_controller.preview_widget = mocked_preview_widget
+        slide_controller.slide_selected = mocked_slide_selected
 
-            # WHEN: The method is called
-            slide_controller.on_slide_selected_index([7])
+        # WHEN: The method is called
+        slide_controller.on_slide_selected_index([7])
 
         # THEN: It should have sent a notification
         mocked_item.is_command.assert_called_once_with()
@@ -642,20 +642,49 @@
             elided_test_string = metrics.elidedText(test_string, QtCore.Qt.ElideRight, label_width)
             mocked_qpainter().drawText.assert_called_once_with(mocked_rect(), QtCore.Qt.AlignLeft, elided_test_string)
 
-    def set_text_test(self):
+    @patch('builtins.super')
+    def set_text_test(self, mocked_super):
         """
         Test the reimplemented setText method
         """
-        with patch('builtins.super') as mocked_super:
-
-            # GIVEN: An instance of InfoLabel and mocked setToolTip method
-            info_label = InfoLabel()
-            set_tool_tip_mock = MagicMock()
-            info_label.setToolTip = set_tool_tip_mock
-
-            # WHEN: Calling the instance method setText
-            info_label.setText('Label Text')
-
-            # THEN: The setToolTip and super class setText methods should have been called with the same text
-            set_tool_tip_mock.assert_called_once_with('Label Text')
-            mocked_super().setText.assert_called_once_with('Label Text')
+        # GIVEN: An instance of InfoLabel and mocked setToolTip method
+        info_label = InfoLabel()
+        set_tool_tip_mock = MagicMock()
+        info_label.setToolTip = set_tool_tip_mock
+
+        # WHEN: Calling the instance method setText
+        info_label.setText('Label Text')
+
+        # THEN: The setToolTip and super class setText methods should have been called with the same text
+        set_tool_tip_mock.assert_called_once_with('Label Text')
+        mocked_super().setText.assert_called_once_with('Label Text')
+
+
+class TestLiveController(TestCase):
+
+    def initial_live_controller_test(self):
+        """
+        Test the initial live slide controller state .
+        """
+        # GIVEN: A new SlideController instance.
+        Registry.create()
+        live_controller = LiveController(None)
+
+        # WHEN: the default controller is built.
+        # THEN: The controller should not be a live controller.
+        self.assertEqual(live_controller.is_live, True, 'The slide controller should be a live controller')
+
+
+class TestPreviewLiveController(TestCase):
+
+    def initial_preview_controller_test(self):
+        """
+        Test the initial preview slide controller state.
+        """
+        # GIVEN: A new SlideController instance.
+        Registry.create()
+        preview_controller = PreviewController(None)
+
+        # WHEN: the default controller is built.
+        # THEN: The controller should not be a live controller.
+        self.assertEqual(preview_controller.is_live, False, 'The slide controller should be a Preview controller')

=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_http.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_http.py	2015-02-26 20:58:54 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_http.py	2015-05-25 20:14:58 +0000
@@ -119,7 +119,7 @@
 
     def bibleserver_get_bibles_test(self):
         """
-        Test getting list of bibles from BibelServer.com
+        Test getting list of bibles from BibleServer.com
         """
         # GIVEN: A new Bible Server extraction class
         handler = BSExtract()
@@ -134,7 +134,7 @@
 
     def biblegateway_get_bibles_test(self):
         """
-        Test getting list of bibles from BibelGateway.com
+        Test getting list of bibles from BibleGateway.com
         """
         # GIVEN: A new Bible Gateway extraction class
         handler = BGExtract()


Follow ups