From 94b926d273849faa7fbde46f15039fc3a69a9816 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 28 Mar 2013 23:08:14 +0100 Subject: [PATCH] added test --- .../test_customform.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/interfaces/openlp_plugins_custom_forms/test_customform.py b/tests/interfaces/openlp_plugins_custom_forms/test_customform.py index 029244220..166ccd672 100644 --- a/tests/interfaces/openlp_plugins_custom_forms/test_customform.py +++ b/tests/interfaces/openlp_plugins_custom_forms/test_customform.py @@ -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.'