HEAD, and futher fixing of mock imports

This commit is contained in:
Raoul Snyman 2013-10-04 23:45:38 +02:00
commit 5481a4718d
14 changed files with 32 additions and 31 deletions

View File

@ -152,7 +152,7 @@ class TestUtils(TestCase):
def get_locale_key_windows_test(self):
"""
Test the get_locale_key(string) function
Test the get_locale_key(string) function on Windows
"""
with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language, \
patch('openlp.core.utils.os') as mocked_os:
@ -171,7 +171,7 @@ class TestUtils(TestCase):
def get_locale_key_linux_test(self):
"""
Test the get_locale_key(string) function
Test the get_locale_key(string) function on Linux
"""
with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language, \
patch('openlp.core.utils.os.name') as mocked_os:

View File

@ -1,3 +1,4 @@
import sip
sip.setapi('QDate', 2)
sip.setapi('QDateTime', 2)
@ -7,7 +8,9 @@ sip.setapi('QTime', 2)
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

View File

@ -7,11 +7,11 @@ import shutil
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):

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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 @@ class TestServiceManager(TestCase):
# 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 @@ class TestServiceManager(TestCase):
"""
# 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 @@ class TestServiceManager(TestCase):
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)

View File

@ -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):

View File

@ -3,12 +3,11 @@ Package to test the openlp.core.lib.settingsform package.
"""
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 @@ class TestSettingsForm(TestCase):
# 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'
assert self.dummy3.call_count == 1, 'dummy3 should have been called once'

View File

@ -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):

View File

@ -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):

View File

@ -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 @@ from openlp.core.lib import Registry
# 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):

View File

@ -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):

View File

@ -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):