some more changes to the test

This commit is contained in:
phill-ridout 2013-02-09 21:23:43 +00:00
parent 7d7da00848
commit 17200d85fc

View File

@ -28,56 +28,42 @@ class TestStartFileRenameForm(TestCase):
del self.main_window del self.main_window
del self.app del self.app
def basic_display_test(self): def window_title_test(self):
""" """
Test FileRenameForm functionality Test the windowTitle of the FileRenameDialog
""" """
# GIVEN: FileRenameForm with no ARGS # GIVEN: A mocked QDialog.exec_() method
# WHEN displaying the UI
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec:
# WHEN: The form is executed with no args
self.form.exec_() self.form.exec_()
# THEN the window title is set as # THEN: the window title is set correctly
self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"')
# GIVEN: FileRenameForm with False ARG # WHEN: The form is executed with False arg
false_arg = False self.form.exec_(False)
# WHEN displaying the UI # THEN: the window title is set correctly
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"')
self.form.exec_(false_arg)
# THEN the window title is set as # WHEN: The form is executed with True arg
self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') self.form.exec_(True)
# GIVEN: FileRenameForm with False ARG # THEN: the window title is set correctly
true_arg = True self.assertEqual(self.form.windowTitle(), u'File Copy', u'The window title should be "File Copy"')
# WHEN displaying the UI and pressing enter def line_edit_focus_test(self):
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: """
self.form.exec_(true_arg) Regression test for bug1067251
Test that the fileNameEdit setFocus has called with True when executed
"""
# GIVEN: A mocked QLineEdit class
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec, \
patch(u'PyQt4.QtGui.QLineEdit') as mocked_line_edit:
# THEN the window title is set as # WHEN: The form is executed with no args
self.assertEqual(self.form.windowTitle(), u'File Copy', u'The window title should be "File Copy"')
# GIVEN: FileRenameForm with defaults
# WHEN displaying the UI
with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec:
self.form.exec_() self.form.exec_()
# THEN the lineEdit should have focus # THEN: the setFocus method of the fileNameEdit has been called with True
self.assertEqual(self.form.fileNameEdit.hasFocus(), True, u'fileNameEdit should have focus.') mocked_line_edit.setFocus.assert_called_with()
# Regression test for bug1067251
# GIVEN: FileRenameForm with defaults
# WHEN displaying the UI
# with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
# self.form.exec_()
# THEN the lineEdit should have focus
#self.assertEqual(self.form.fileNameEdit.hasFocus(), u'File Rename', u'The window title should be "File Rename"')