forked from openlp/openlp
Fix the unit test framework
This commit is contained in:
parent
e921e63e35
commit
62b1653c46
@ -7,7 +7,3 @@ sip.setapi(u'QTime', 2)
|
|||||||
sip.setapi(u'QUrl', 2)
|
sip.setapi(u'QUrl', 2)
|
||||||
sip.setapi(u'QVariant', 2)
|
sip.setapi(u'QVariant', 2)
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
|
||||||
|
|
||||||
# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication.
|
|
||||||
application = QtGui.QApplication([])
|
|
||||||
|
@ -20,7 +20,7 @@ class TestImageManager(TestCase):
|
|||||||
Create the UI
|
Create the UI
|
||||||
"""
|
"""
|
||||||
Registry.create()
|
Registry.create()
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication([])
|
||||||
ScreenList.create(self.app.desktop())
|
ScreenList.create(self.app.desktop())
|
||||||
self.image_manager = ImageManager()
|
self.image_manager = ImageManager()
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ from openlp.core.lib import Registry
|
|||||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestRegistry(TestCase):
|
class TestRegistry(TestCase):
|
||||||
|
|
||||||
def registry_service_test(self):
|
def registry_service_test(self):
|
||||||
|
@ -7,7 +7,7 @@ from unittest import TestCase
|
|||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
from openlp.core.lib import ScreenList
|
from openlp.core.lib import Registry, ScreenList
|
||||||
|
|
||||||
|
|
||||||
SCREEN = {
|
SCREEN = {
|
||||||
@ -23,18 +23,22 @@ class TestScreenList(TestCase):
|
|||||||
"""
|
"""
|
||||||
Set up the components need for all tests.
|
Set up the components need for all tests.
|
||||||
"""
|
"""
|
||||||
self.application = QtGui.QApplication.instance()
|
Registry.create()
|
||||||
|
self.application = QtGui.QApplication([])
|
||||||
|
self.application.setOrganizationName(u'OpenLP-tests')
|
||||||
|
self.application.setOrganizationDomain(u'openlp.org')
|
||||||
self.screens = ScreenList.create(self.application.desktop())
|
self.screens = ScreenList.create(self.application.desktop())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
Delete QApplication.
|
Delete QApplication.
|
||||||
"""
|
"""
|
||||||
|
del self.screens
|
||||||
del self.application
|
del self.application
|
||||||
|
|
||||||
def add_desktop_test(self):
|
def add_desktop_test(self):
|
||||||
"""
|
"""
|
||||||
Test the ScreenList class' screen_count_changed method to check if new monitors are detected by OpenLP.
|
Test the ScreenList class' - screen_count_changed method to check if new monitors are detected by OpenLP.
|
||||||
"""
|
"""
|
||||||
# GIVEN: The screen list.
|
# GIVEN: The screen list.
|
||||||
old_screens = copy.deepcopy(self.screens.screen_list)
|
old_screens = copy.deepcopy(self.screens.screen_list)
|
||||||
@ -52,4 +56,3 @@ class TestScreenList(TestCase):
|
|||||||
|
|
||||||
# THEN: The screens should be identically.
|
# THEN: The screens should be identically.
|
||||||
assert SCREEN == new_screens.pop(), u'The new screen should be identically to the screen defined above.'
|
assert SCREEN == new_screens.pop(), u'The new screen should be identically to the screen defined above.'
|
||||||
|
|
||||||
|
@ -7,7 +7,3 @@ sip.setapi(u'QTime', 2)
|
|||||||
sip.setapi(u'QUrl', 2)
|
sip.setapi(u'QUrl', 2)
|
||||||
sip.setapi(u'QVariant', 2)
|
sip.setapi(u'QVariant', 2)
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
|
||||||
|
|
||||||
# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication.
|
|
||||||
application = QtGui.QApplication([])
|
|
||||||
|
@ -6,7 +6,7 @@ import sys
|
|||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from mock import MagicMock, patch
|
from mock import MagicMock
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib.pluginmanager import PluginManager
|
from openlp.core.lib.pluginmanager import PluginManager
|
||||||
@ -26,7 +26,7 @@ class TestPluginManager(TestCase):
|
|||||||
Settings().set_filename(self.ini_file)
|
Settings().set_filename(self.ini_file)
|
||||||
Registry.create()
|
Registry.create()
|
||||||
Registry().register(u'service_list', MagicMock())
|
Registry().register(u'service_list', MagicMock())
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication([])
|
||||||
self.main_window = QtGui.QMainWindow()
|
self.main_window = QtGui.QMainWindow()
|
||||||
Registry().register(u'main_window', self.main_window)
|
Registry().register(u'main_window', self.main_window)
|
||||||
self.plugins_dir = os.path.abspath(os.path.join(os.path.basename(__file__), u'..', u'openlp', u'plugins'))
|
self.plugins_dir = os.path.abspath(os.path.join(os.path.basename(__file__), u'..', u'openlp', u'plugins'))
|
||||||
@ -34,6 +34,7 @@ class TestPluginManager(TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.unlink(self.ini_file)
|
os.unlink(self.ini_file)
|
||||||
del self.app
|
del self.app
|
||||||
|
del self.main_window
|
||||||
|
|
||||||
def find_plugins_test(self):
|
def find_plugins_test(self):
|
||||||
"""
|
"""
|
||||||
|
@ -14,8 +14,8 @@ class TestStartFileRenameForm(TestCase):
|
|||||||
"""
|
"""
|
||||||
Create the UI
|
Create the UI
|
||||||
"""
|
"""
|
||||||
registry = Registry.create()
|
Registry.create()
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication([])
|
||||||
self.main_window = QtGui.QMainWindow()
|
self.main_window = QtGui.QMainWindow()
|
||||||
Registry().register(u'main_window', self.main_window)
|
Registry().register(u'main_window', self.main_window)
|
||||||
self.form = filerenameform.FileRenameForm()
|
self.form = filerenameform.FileRenameForm()
|
||||||
@ -78,6 +78,6 @@ class TestStartFileRenameForm(TestCase):
|
|||||||
# WHEN: 'Typing' a string containing invalid file characters.
|
# WHEN: 'Typing' a string containing invalid file characters.
|
||||||
QtTest.QTest.keyClicks(self.form.fileNameEdit, u'I/n\\v?a*l|i<d> \F[i\l]e" :N+a%me')
|
QtTest.QTest.keyClicks(self.form.fileNameEdit, u'I/n\\v?a*l|i<d> \F[i\l]e" :N+a%me')
|
||||||
|
|
||||||
# THEN: The text in the QLineEdit should be the same as the input string with the invalid chatacters filtered
|
# THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered
|
||||||
# out.
|
# out.
|
||||||
self.assertEqual(self.form.fileNameEdit.text(), u'Invalid File Name')
|
self.assertEqual(self.form.fileNameEdit.text(), u'Invalid File Name')
|
||||||
|
@ -18,7 +18,7 @@ class TestStartNoteDialog(TestCase):
|
|||||||
Create the UI
|
Create the UI
|
||||||
"""
|
"""
|
||||||
Registry.create()
|
Registry.create()
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication([])
|
||||||
ScreenList.create(self.app.desktop())
|
ScreenList.create(self.app.desktop())
|
||||||
Registry().register(u'application', MagicMock())
|
Registry().register(u'application', MagicMock())
|
||||||
self.main_window = MainWindow()
|
self.main_window = MainWindow()
|
||||||
|
@ -17,7 +17,7 @@ class TestStartNoteDialog(TestCase):
|
|||||||
Create the UI
|
Create the UI
|
||||||
"""
|
"""
|
||||||
Registry.create()
|
Registry.create()
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication([])
|
||||||
self.main_window = QtGui.QMainWindow()
|
self.main_window = QtGui.QMainWindow()
|
||||||
Registry().register(u'main_window', self.main_window)
|
Registry().register(u'main_window', self.main_window)
|
||||||
self.form = servicenoteform.ServiceNoteForm()
|
self.form = servicenoteform.ServiceNoteForm()
|
||||||
|
@ -17,7 +17,7 @@ class TestStartTimeDialog(TestCase):
|
|||||||
Create the UI
|
Create the UI
|
||||||
"""
|
"""
|
||||||
Registry.create()
|
Registry.create()
|
||||||
self.app = QtGui.QApplication.instance()
|
self.app = QtGui.QApplication([])
|
||||||
self.main_window = QtGui.QMainWindow()
|
self.main_window = QtGui.QMainWindow()
|
||||||
Registry().register(u'main_window', self.main_window)
|
Registry().register(u'main_window', self.main_window)
|
||||||
self.form = starttimeform.StartTimeForm()
|
self.form = starttimeform.StartTimeForm()
|
||||||
|
Loading…
Reference in New Issue
Block a user