added test

This commit is contained in:
Andreas Preikschat 2013-03-28 23:08:14 +01:00
parent b139b6a4eb
commit 94b926d273

View File

@ -4,7 +4,7 @@ Module to test the custom edit form.
from unittest import TestCase
from mock import MagicMock, patch
from PyQt4 import QtGui
from PyQt4 import QtGui, QtTest, QtCore
from openlp.core.lib import Registry
# Import needed due to import problems.
@ -36,9 +36,9 @@ class TestCustomFrom(TestCase):
del self.main_window
del self.app
def load_custom_test(self):
def load_custom(self):
"""
Test the EditCustomForm defaults are correct
Test the load_custom() method.
"""
# GIVEN: A mocked QDialog.exec_() method
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec:
@ -50,3 +50,15 @@ class TestCustomFrom(TestCase):
self.assertEqual(self.form.title_edit.text(), u'', u'The title edit should be empty')
self.assertEqual(self.form.credit_edit.text(), u'', u'The credit edit should be empty')
def on_add_button_clicked_test(self):
"""
Test the on_add_button_clicked_test method / add_button button.
"""
# GIVEN: A mocked QDialog.exec_() method
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec:
# WHEN: Show the dialog and add a new slide.
self.form.exec_()
QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton)
#THEN: One slide should be added.
assert self.form.slide_list_view.count() == 1, u'There should be one slide be added.'