← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/update-mock into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/update-mock into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/update-mock/+merge/189478

fix the interface tests
-- 
https://code.launchpad.net/~raoul-snyman/openlp/update-mock/+merge/189478
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'tests/interfaces/__init__.py'
--- tests/interfaces/__init__.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/__init__.py	2013-10-05 18:17:17 +0000
@@ -1,3 +1,4 @@
+
 import sip
 sip.setapi('QDate', 2)
 sip.setapi('QDateTime', 2)
@@ -7,7 +8,9 @@
 sip.setapi('QUrl', 2)
 sip.setapi('QVariant', 2)
 
-#from PyQt4 import QtGui
+import sys
 
-# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" an QApplication.
-#application = QtGui.QApplication([])
+if sys.version_info[1] >= 3:
+    from unittest.mock import patch, MagicMock
+else:
+    from mock import patch, MagicMock

=== modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py'
--- tests/interfaces/openlp_core_lib/test_pluginmanager.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_lib/test_pluginmanager.py	2013-10-05 18:17:17 +0000
@@ -7,11 +7,11 @@
 from tempfile import mkstemp, mkdtemp
 from unittest import TestCase
 
-from mock import MagicMock
 from PyQt4 import QtGui
 
 from openlp.core.lib.pluginmanager import PluginManager
 from openlp.core.lib import Registry, Settings
+from tests.interfaces import MagicMock
 
 
 class TestPluginManager(TestCase):

=== modified file 'tests/interfaces/openlp_core_ui/test_filerenamedialog.py'
--- tests/interfaces/openlp_core_ui/test_filerenamedialog.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_filerenamedialog.py	2013-10-05 18:17:17 +0000
@@ -3,10 +3,11 @@
 """
 from unittest import TestCase
 
-from mock import MagicMock, patch
+from PyQt4 import QtGui, QtTest
+
 from openlp.core.lib import Registry
 from openlp.core.ui import filerenameform
-from PyQt4 import QtGui, QtTest
+from tests.interfaces import MagicMock, patch
 
 
 class TestStartFileRenameForm(TestCase):

=== modified file 'tests/interfaces/openlp_core_ui/test_listpreviewwidget.py'
--- tests/interfaces/openlp_core_ui/test_listpreviewwidget.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_listpreviewwidget.py	2013-10-05 18:17:17 +0000
@@ -3,12 +3,12 @@
 """
 
 from unittest import TestCase
-from mock import MagicMock, patch
 
 from PyQt4 import QtGui
 
 from openlp.core.lib import Registry, ServiceItem
 from openlp.core.ui import listpreviewwidget
+from tests.interfaces import MagicMock, patch
 from tests.utils.osdinteraction import read_service_from_file
 
 

=== modified file 'tests/interfaces/openlp_core_ui/test_mainwindow.py'
--- tests/interfaces/openlp_core_ui/test_mainwindow.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_mainwindow.py	2013-10-05 18:17:17 +0000
@@ -2,12 +2,12 @@
 Package to test the openlp.core.ui.mainwindow package.
 """
 from unittest import TestCase
-from mock import MagicMock, patch
 
 from PyQt4 import QtGui
 
 from openlp.core.lib import Registry
 from openlp.core.ui.mainwindow import MainWindow
+from tests.interfaces import MagicMock, patch
 
 
 class TestMainWindow(TestCase):

=== modified file 'tests/interfaces/openlp_core_ui/test_servicemanager.py'
--- tests/interfaces/openlp_core_ui/test_servicemanager.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_servicemanager.py	2013-10-05 18:17:17 +0000
@@ -3,12 +3,12 @@
 """
 
 from unittest import TestCase
-from mock import MagicMock, Mock, patch
 
 from PyQt4 import QtGui
 
 from openlp.core.lib import Registry, ScreenList, ServiceItem
 from openlp.core.ui.mainwindow import MainWindow
+from tests.interfaces import MagicMock, patch
 
 
 class TestServiceManager(TestCase):
@@ -41,7 +41,7 @@
         # WHEN I have an empty display
         # THEN the count of items should be zero
         self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0,
-            'The service manager list should be empty ')
+                         'The service manager list should be empty ')
 
     def context_menu_test(self):
         """
@@ -49,8 +49,8 @@
         """
         # GIVEN: A service item added
         with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \
-                patch('PyQt4.QtGui.QWidget.mapToGlobal') as mocked_map_to_global, \
-                patch('PyQt4.QtGui.QMenu.exec_') as mocked_exec:
+                patch('PyQt4.QtGui.QWidget.mapToGlobal'), \
+                patch('PyQt4.QtGui.QMenu.exec_'):
             mocked_item = MagicMock()
             mocked_item.parent.return_value = None
             mocked_item_at_method.return_value = mocked_item
@@ -61,12 +61,12 @@
             self.service_manager.service_items = [{'service_item': service_item}]
             q_point = None
             # Mocked actions.
-            self.service_manager.edit_action.setVisible = Mock()
-            self.service_manager.create_custom_action.setVisible = Mock()
-            self.service_manager.maintain_action.setVisible = Mock()
-            self.service_manager.notes_action.setVisible = Mock()
-            self.service_manager.time_action.setVisible = Mock()
-            self.service_manager.auto_start_action.setVisible = Mock()
+            self.service_manager.edit_action.setVisible = MagicMock()
+            self.service_manager.create_custom_action.setVisible = MagicMock()
+            self.service_manager.maintain_action.setVisible = MagicMock()
+            self.service_manager.notes_action.setVisible = MagicMock()
+            self.service_manager.time_action.setVisible = MagicMock()
+            self.service_manager.auto_start_action.setVisible = MagicMock()
 
             # WHEN: Show the context menu.
             self.service_manager.context_menu(q_point)

=== modified file 'tests/interfaces/openlp_core_ui/test_servicenotedialog.py'
--- tests/interfaces/openlp_core_ui/test_servicenotedialog.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_servicenotedialog.py	2013-10-05 18:17:17 +0000
@@ -2,12 +2,12 @@
 Package to test the openlp.core.ui package.
 """
 from unittest import TestCase
-from mock import patch
 
 from PyQt4 import QtCore, QtGui, QtTest
 
 from openlp.core.lib import Registry
 from openlp.core.ui import servicenoteform
+from tests.interfaces import patch
 
 
 class TestStartNoteDialog(TestCase):

=== modified file 'tests/interfaces/openlp_core_ui/test_settings_form.py'
--- tests/interfaces/openlp_core_ui/test_settings_form.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_settings_form.py	2013-10-05 18:17:17 +0000
@@ -3,12 +3,11 @@
 """
 from unittest import TestCase
 
-from mock import MagicMock, patch
-
 from PyQt4 import QtCore, QtTest, QtGui
 
 from openlp.core.ui import settingsform
 from openlp.core.lib import Registry, ScreenList
+from tests.interfaces import MagicMock, patch
 
 
 SCREEN = {
@@ -168,4 +167,4 @@
         # THEN: Images_regenerate should have been added.
         assert self.dummy1.call_count == 1, 'dummy1 should have been called once'
         assert self.dummy2.call_count == 1, 'dummy2 should have been called once'
-        assert self.dummy3.call_count == 1, 'dummy3 should have been called once'
\ No newline at end of file
+        assert self.dummy3.call_count == 1, 'dummy3 should have been called once'

=== modified file 'tests/interfaces/openlp_core_ui/test_starttimedialog.py'
--- tests/interfaces/openlp_core_ui/test_starttimedialog.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_core_ui/test_starttimedialog.py	2013-10-05 18:17:17 +0000
@@ -2,13 +2,12 @@
 Package to test the openlp.core.ui package.
 """
 from unittest import TestCase
-from mock import MagicMock, patch
 
 from PyQt4 import QtCore, QtGui, QtTest
 
 from openlp.core.lib import Registry
 from openlp.core.ui import starttimeform
-
+from tests.interfaces import MagicMock, patch
 
 
 class TestStartTimeDialog(TestCase):

=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_http.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_http.py	2013-09-09 21:10:40 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_http.py	2013-10-05 18:17:17 +0000
@@ -1,12 +1,11 @@
 """
     Package to test the openlp.plugin.bible.lib.https package.
 """
-
 from unittest import TestCase
-from mock import MagicMock
 
 from openlp.core.lib import Registry
 from openlp.plugins.bibles.lib.http import BGExtract, CWExtract
+from tests.interfaces import MagicMock
 
 
 class TestBibleHTTP(TestCase):

=== modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py'
--- tests/interfaces/openlp_plugins/custom/forms/test_customform.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py	2013-10-05 18:17:17 +0000
@@ -2,7 +2,6 @@
 Module to test the EditCustomForm.
 """
 from unittest import TestCase
-from mock import MagicMock, patch
 
 from PyQt4 import QtGui, QtTest, QtCore
 
@@ -10,6 +9,7 @@
 # Import needed due to import problems.
 from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
 from openlp.plugins.custom.forms.editcustomform import EditCustomForm
+from tests.interfaces import MagicMock, patch
 
 
 class TestEditCustomForm(TestCase):

=== modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py'
--- tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py	2013-10-05 18:17:17 +0000
@@ -2,12 +2,12 @@
 Module to test the EditCustomSlideForm.
 """
 from unittest import TestCase
-from mock import MagicMock, patch
 
 from PyQt4 import QtGui
 
 from openlp.core.lib import Registry
 from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
+from tests.interfaces import MagicMock, patch
 
 
 class TestEditCustomSlideForm(TestCase):

=== modified file 'tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py'
--- tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py	2013-10-05 18:17:17 +0000
@@ -1,13 +1,13 @@
 """
 Package to test the openlp.plugins.songs.forms.editsongform package.
 """
-from mock import MagicMock
 from unittest import TestCase
 
 from PyQt4 import QtGui
 
 from openlp.core.lib import Registry
 from openlp.plugins.songs.forms.editsongform import EditSongForm
+from tests.interfaces import MagicMock
 
 
 class TestEditSongForm(TestCase):


Follow ups