forked from openlp/openlp
added tests
This commit is contained in:
parent
e2b8dc54f3
commit
0fb24d2233
@ -257,6 +257,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
# We must have at least one slide.
|
# We must have at least one slide.
|
||||||
if self.slide_list_view.count() == 0:
|
if self.slide_list_view.count() == 0:
|
||||||
critical_error_message_box(message=translate('CustomPlugin.EditCustomForm',
|
critical_error_message_box(message=translate('CustomPlugin.EditCustomForm',
|
||||||
'You need to add at least one slide'))
|
'You need to add at least one slide.'))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -62,3 +62,45 @@ class TestEditCustomForm(TestCase):
|
|||||||
QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton)
|
||||||
#THEN: One slide should be added.
|
#THEN: One slide should be added.
|
||||||
assert self.form.slide_list_view.count() == 1, u'There should be one slide added.'
|
assert self.form.slide_list_view.count() == 1, u'There should be one slide added.'
|
||||||
|
|
||||||
|
def validate_not_valid_part1_test(self):
|
||||||
|
"""
|
||||||
|
Test the _validate() method.
|
||||||
|
"""
|
||||||
|
# GIVEN: Mocked methods.
|
||||||
|
with patch(u'openlp.plugins.custom.forms.editcustomform.critical_error_message_box') as \
|
||||||
|
mocked_critical_error_message_box:
|
||||||
|
mocked_displayText = MagicMock()
|
||||||
|
mocked_displayText.return_value = u''
|
||||||
|
self.form.title_edit.displayText = mocked_displayText
|
||||||
|
mocked_setFocus = MagicMock()
|
||||||
|
self.form.title_edit.setFocus = mocked_setFocus
|
||||||
|
|
||||||
|
# WHEN: Call the method.
|
||||||
|
result = self.form._validate()
|
||||||
|
|
||||||
|
# THEN: The validate method should have returned False.
|
||||||
|
assert not result, u'The _validate() method should have retured False'
|
||||||
|
mocked_setFocus.assert_called_with()
|
||||||
|
mocked_critical_error_message_box.assert_called_with(message=u'You need to type in a title.')
|
||||||
|
|
||||||
|
def validate_not_valid_part2_test(self):
|
||||||
|
"""
|
||||||
|
Test the _validate() method.
|
||||||
|
"""
|
||||||
|
# GIVEN: Mocked methods.
|
||||||
|
with patch(u'openlp.plugins.custom.forms.editcustomform.critical_error_message_box') as \
|
||||||
|
mocked_critical_error_message_box:
|
||||||
|
mocked_displayText = MagicMock()
|
||||||
|
mocked_displayText.return_value = u'something'
|
||||||
|
self.form.title_edit.displayText = mocked_displayText
|
||||||
|
mocked_count = MagicMock()
|
||||||
|
mocked_count.return_value = 0
|
||||||
|
self.form.slide_list_view.count = mocked_count
|
||||||
|
|
||||||
|
# WHEN: Call the method.
|
||||||
|
result = self.form._validate()
|
||||||
|
|
||||||
|
# THEN: The validate method should have returned False.
|
||||||
|
assert not result, u'The _validate() method should have retured False'
|
||||||
|
mocked_critical_error_message_box.assert_called_with(message=u'You need to add at least one slide.')
|
||||||
|
Loading…
Reference in New Issue
Block a user