Missed a few GIVEN, WHEN, THENS

This commit is contained in:
phill-ridout 2013-03-31 11:55:58 +01:00
parent 7bae770458
commit 8864e1e51b

View File

@ -70,9 +70,9 @@ class TestSongShowPlusImport(TestCase):
# THEN: The importer object should not be None # THEN: The importer object should not be None
self.assertIsNotNone(importer, u'Import should not be none') self.assertIsNotNone(importer, u'Import should not be none')
def import_source_test(self): def invalid_import_source_test(self):
""" """
Test SongShowPlusImport.doImport handles different import_source values Test SongShowPlusImport.doImport handles different invalid import_source values
""" """
# GIVEN: A mocked out SongImport class, and a mocked out "manager" # GIVEN: A mocked out SongImport class, and a mocked out "manager"
with patch(u'openlp.plugins.songs.lib.songshowplusimport.SongImport'): with patch(u'openlp.plugins.songs.lib.songshowplusimport.SongImport'):
@ -82,30 +82,19 @@ class TestSongShowPlusImport(TestCase):
importer.import_wizard = mocked_import_wizard importer.import_wizard = mocked_import_wizard
importer.stop_import_flag = True importer.stop_import_flag = True
# WHEN: Import source is a string # WHEN: Import source is not a list
importer.import_source = u'not a list' for source in [u'not a list', 0]:
importer.import_source = source
# THEN: doImport should return none and the progress bar maximum should not be set.
self.assertIsNone(importer.doImport(), u'doImport should return None when import_source is not a list')
self.assertEquals(mocked_import_wizard.progress_bar.setMaximum.called, False,
u'setMaxium on import_wizard.progress_bar should not have been called')
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
with patch(u'openlp.plugins.songs.lib.songshowplusimport.SongImport'):
mocked_manager = MagicMock()
mocked_import_wizard = MagicMock()
importer = SongShowPlusImport(mocked_manager)
importer.import_wizard = mocked_import_wizard
importer.stop_import_flag = True
# WHEN: Import source is an int
importer.import_source = 0
# THEN: doImport should return none and the progress bar maximum should not be set. # THEN: doImport should return none and the progress bar maximum should not be set.
self.assertIsNone(importer.doImport(), u'doImport should return None when import_source is not a list') self.assertIsNone(importer.doImport(), u'doImport should return None when import_source is not a list')
self.assertEquals(mocked_import_wizard.progress_bar.setMaximum.called, False, self.assertEquals(mocked_import_wizard.progress_bar.setMaximum.called, False,
u'setMaxium on import_wizard.progress_bar should not have been called') u'setMaxium on import_wizard.progress_bar should not have been called')
def valid_import_source_test(self):
"""
Test SongShowPlusImport.doImport handles different invalid import_source values
"""
# GIVEN: A mocked out SongImport class, and a mocked out "manager" # GIVEN: A mocked out SongImport class, and a mocked out "manager"
with patch(u'openlp.plugins.songs.lib.songshowplusimport.SongImport'): with patch(u'openlp.plugins.songs.lib.songshowplusimport.SongImport'):
mocked_manager = MagicMock() mocked_manager = MagicMock()