forked from openlp/openlp
Head
This commit is contained in:
commit
b794623e7f
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import sip
|
import sip
|
||||||
sip.setapi('QDate', 2)
|
sip.setapi('QDate', 2)
|
||||||
sip.setapi('QDateTime', 2)
|
sip.setapi('QDateTime', 2)
|
||||||
@ -7,7 +8,9 @@ sip.setapi('QTime', 2)
|
|||||||
sip.setapi('QUrl', 2)
|
sip.setapi('QUrl', 2)
|
||||||
sip.setapi('QVariant', 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.
|
if sys.version_info[1] >= 3:
|
||||||
#application = QtGui.QApplication([])
|
from unittest.mock import patch, MagicMock
|
||||||
|
else:
|
||||||
|
from mock import patch, MagicMock
|
||||||
|
@ -7,12 +7,12 @@ import shutil
|
|||||||
from tempfile import mkstemp, mkdtemp
|
from tempfile import mkstemp, mkdtemp
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from mock import MagicMock
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.common import Settings
|
from openlp.core.common import Settings
|
||||||
from openlp.core.lib.pluginmanager import PluginManager
|
from openlp.core.lib.pluginmanager import PluginManager
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
|
from tests.interfaces import MagicMock
|
||||||
|
|
||||||
|
|
||||||
class TestPluginManager(TestCase):
|
class TestPluginManager(TestCase):
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from mock import MagicMock, patch
|
from PyQt4 import QtGui, QtTest
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.core.ui import filerenameform
|
from openlp.core.ui import filerenameform
|
||||||
from PyQt4 import QtGui, QtTest
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestStartFileRenameForm(TestCase):
|
class TestStartFileRenameForm(TestCase):
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Registry, ServiceItem
|
from openlp.core.lib import Registry, ServiceItem
|
||||||
from openlp.core.ui import listpreviewwidget
|
from openlp.core.ui import listpreviewwidget
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
from tests.utils.osdinteraction import read_service_from_file
|
from tests.utils.osdinteraction import read_service_from_file
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
Package to test the openlp.core.ui.mainwindow package.
|
Package to test the openlp.core.ui.mainwindow package.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestMainWindow(TestCase):
|
class TestMainWindow(TestCase):
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock, Mock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Registry, ScreenList, ServiceItem
|
from openlp.core.lib import Registry, ScreenList, ServiceItem
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestServiceManager(TestCase):
|
class TestServiceManager(TestCase):
|
||||||
@ -41,7 +41,7 @@ class TestServiceManager(TestCase):
|
|||||||
# WHEN I have an empty display
|
# WHEN I have an empty display
|
||||||
# THEN the count of items should be zero
|
# THEN the count of items should be zero
|
||||||
self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0,
|
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):
|
def context_menu_test(self):
|
||||||
"""
|
"""
|
||||||
@ -49,8 +49,8 @@ class TestServiceManager(TestCase):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: A service item added
|
# GIVEN: A service item added
|
||||||
with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \
|
with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \
|
||||||
patch('PyQt4.QtGui.QWidget.mapToGlobal') as mocked_map_to_global, \
|
patch('PyQt4.QtGui.QWidget.mapToGlobal'), \
|
||||||
patch('PyQt4.QtGui.QMenu.exec_') as mocked_exec:
|
patch('PyQt4.QtGui.QMenu.exec_'):
|
||||||
mocked_item = MagicMock()
|
mocked_item = MagicMock()
|
||||||
mocked_item.parent.return_value = None
|
mocked_item.parent.return_value = None
|
||||||
mocked_item_at_method.return_value = mocked_item
|
mocked_item_at_method.return_value = mocked_item
|
||||||
@ -61,12 +61,12 @@ class TestServiceManager(TestCase):
|
|||||||
self.service_manager.service_items = [{'service_item': service_item}]
|
self.service_manager.service_items = [{'service_item': service_item}]
|
||||||
q_point = None
|
q_point = None
|
||||||
# Mocked actions.
|
# Mocked actions.
|
||||||
self.service_manager.edit_action.setVisible = Mock()
|
self.service_manager.edit_action.setVisible = MagicMock()
|
||||||
self.service_manager.create_custom_action.setVisible = Mock()
|
self.service_manager.create_custom_action.setVisible = MagicMock()
|
||||||
self.service_manager.maintain_action.setVisible = Mock()
|
self.service_manager.maintain_action.setVisible = MagicMock()
|
||||||
self.service_manager.notes_action.setVisible = Mock()
|
self.service_manager.notes_action.setVisible = MagicMock()
|
||||||
self.service_manager.time_action.setVisible = Mock()
|
self.service_manager.time_action.setVisible = MagicMock()
|
||||||
self.service_manager.auto_start_action.setVisible = Mock()
|
self.service_manager.auto_start_action.setVisible = MagicMock()
|
||||||
|
|
||||||
# WHEN: Show the context menu.
|
# WHEN: Show the context menu.
|
||||||
self.service_manager.context_menu(q_point)
|
self.service_manager.context_menu(q_point)
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
Package to test the openlp.core.ui package.
|
Package to test the openlp.core.ui package.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui, QtTest
|
from PyQt4 import QtCore, QtGui, QtTest
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.core.ui import servicenoteform
|
from openlp.core.ui import servicenoteform
|
||||||
|
from tests.interfaces import patch
|
||||||
|
|
||||||
|
|
||||||
class TestStartNoteDialog(TestCase):
|
class TestStartNoteDialog(TestCase):
|
||||||
|
@ -3,12 +3,11 @@ Package to test the openlp.core.lib.settingsform package.
|
|||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from mock import MagicMock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtTest, QtGui
|
from PyQt4 import QtCore, QtTest, QtGui
|
||||||
|
|
||||||
from openlp.core.ui import settingsform
|
from openlp.core.ui import settingsform
|
||||||
from openlp.core.lib import Registry, ScreenList
|
from openlp.core.lib import Registry, ScreenList
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
SCREEN = {
|
SCREEN = {
|
||||||
@ -168,4 +167,4 @@ class TestSettingsForm(TestCase):
|
|||||||
# THEN: Images_regenerate should have been added.
|
# THEN: Images_regenerate should have been added.
|
||||||
assert self.dummy1.call_count == 1, 'dummy1 should have been called once'
|
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.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'
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
Package to test the openlp.core.ui package.
|
Package to test the openlp.core.ui package.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui, QtTest
|
from PyQt4 import QtCore, QtGui, QtTest
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.core.ui import starttimeform
|
from openlp.core.ui import starttimeform
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestStartTimeDialog(TestCase):
|
class TestStartTimeDialog(TestCase):
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
Package to test the openlp.plugin.bible.lib.https package.
|
Package to test the openlp.plugin.bible.lib.https package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock
|
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.plugins.bibles.lib.http import BGExtract, CWExtract
|
from openlp.plugins.bibles.lib.http import BGExtract, CWExtract
|
||||||
|
from tests.interfaces import MagicMock
|
||||||
|
|
||||||
|
|
||||||
class TestBibleHTTP(TestCase):
|
class TestBibleHTTP(TestCase):
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
Module to test the EditCustomForm.
|
Module to test the EditCustomForm.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtTest, QtCore
|
from PyQt4 import QtGui, QtTest, QtCore
|
||||||
|
|
||||||
@ -10,6 +9,7 @@ from openlp.core.lib import Registry
|
|||||||
# Import needed due to import problems.
|
# Import needed due to import problems.
|
||||||
from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
|
from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
|
||||||
from openlp.plugins.custom.forms.editcustomform import EditCustomForm
|
from openlp.plugins.custom.forms.editcustomform import EditCustomForm
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestEditCustomForm(TestCase):
|
class TestEditCustomForm(TestCase):
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
Module to test the EditCustomSlideForm.
|
Module to test the EditCustomSlideForm.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from mock import MagicMock, patch
|
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
|
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
|
||||||
|
from tests.interfaces import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
class TestEditCustomSlideForm(TestCase):
|
class TestEditCustomSlideForm(TestCase):
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
Package to test the openlp.plugins.songs.forms.editsongform package.
|
Package to test the openlp.plugins.songs.forms.editsongform package.
|
||||||
"""
|
"""
|
||||||
from mock import MagicMock
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Registry
|
from openlp.core.lib import Registry
|
||||||
from openlp.plugins.songs.forms.editsongform import EditSongForm
|
from openlp.plugins.songs.forms.editsongform import EditSongForm
|
||||||
|
from tests.interfaces import MagicMock
|
||||||
|
|
||||||
|
|
||||||
class TestEditSongForm(TestCase):
|
class TestEditSongForm(TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user