From 1abc6e6316eb0256777a70d98d300fe131a4a7cc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 22 Dec 2017 17:15:30 +0000 Subject: [PATCH] functional more bits --- .../openlp_plugins/custom/test_mediaitem.py | 10 ++++---- .../openlp_plugins/images/test_imagetab.py | 10 ++++---- .../openlp_plugins/images/test_lib.py | 24 +++++++++---------- .../openlp_plugins/images/test_upgrade.py | 4 ++-- .../test_presentationcontroller.py | 8 +++---- .../openlp_plugins/songs/test_songselect.py | 6 ++--- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/functional/openlp_plugins/custom/test_mediaitem.py b/tests/functional/openlp_plugins/custom/test_mediaitem.py index d75fa727d..90f4810ef 100644 --- a/tests/functional/openlp_plugins/custom/test_mediaitem.py +++ b/tests/functional/openlp_plugins/custom/test_mediaitem.py @@ -73,7 +73,7 @@ class TestMediaItem(TestCase, TestMixin): item = self.media_item.service_load(service_item) # THEN: the processing should be ignored - self.assertEqual(item, None, 'The Service item is inactive so processing should be bypassed') + assert item is None, 'The Service item is inactive so processing should be bypassed' def test_service_load_basic_custom_false(self): """ @@ -95,8 +95,8 @@ class TestMediaItem(TestCase, TestMixin): self.media_item.service_load(service_item) # THEN: the item should not be added to the database. - self.assertEqual(self.media_item.create_from_service_item.call_count, 0, - 'The item should not have been added to the database') + assert self.media_item.create_from_service_item.call_count == 0, \ + 'The item should not have been added to the database' def test_service_load_basic_custom_true(self): """ @@ -118,5 +118,5 @@ class TestMediaItem(TestCase, TestMixin): self.media_item.service_load(service_item) # THEN: the item should not be added to the database. - self.assertEqual(self.media_item.create_from_service_item.call_count, 1, - 'The item should have been added to the database') + assert self.media_item.create_from_service_item.call_count == 1, \ + 'The item should have been added to the database' diff --git a/tests/functional/openlp_plugins/images/test_imagetab.py b/tests/functional/openlp_plugins/images/test_imagetab.py index 1000001c2..329fac0b8 100644 --- a/tests/functional/openlp_plugins/images/test_imagetab.py +++ b/tests/functional/openlp_plugins/images/test_imagetab.py @@ -74,8 +74,8 @@ class TestImageMediaItem(TestCase, TestMixin): # WHEN: the save is invoked self.form.save() # THEN: the post process should not be requested - self.assertEqual(0, self.form.settings_form.register_post_process.call_count, - 'Image Post processing should not have been requested') + assert 0 == self.form.settings_form.register_post_process.call_count, \ + 'Image Post processing should not have been requested' def test_save_tab_change(self): """ @@ -86,7 +86,7 @@ class TestImageMediaItem(TestCase, TestMixin): # WHEN: the save is invoked self.form.save() # THEN: the post process should be requested - self.assertEqual(1, self.form.settings_form.register_post_process.call_count, - 'Image Post processing should have been requested') + assert 1 == self.form.settings_form.register_post_process.call_count, \ + 'Image Post processing should have been requested' # THEN: The color should be set - self.assertEqual(self.form.background_color, '#999999', 'The updated color should have been saved') + assert self.form.background_color == '#999999', 'The updated color should have been saved' diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index b6e990ebb..09092a0f0 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -98,8 +98,8 @@ class TestImageMediaItem(TestCase): self.media_item.save_new_images_list(image_list) # THEN: The save_object() method should not have been called - self.assertEquals(self.media_item.manager.save_object.call_count, 0, - 'The save_object() method should not have been called') + assert self.media_item.manager.save_object.call_count == 0, \ + 'The save_object() method should not have been called' @patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') def test_save_new_images_list_single_image_with_reload(self, mocked_load_full_list): @@ -115,7 +115,7 @@ class TestImageMediaItem(TestCase): self.media_item.save_new_images_list(image_list, reload_list=True) # THEN: load_full_list() should have been called - self.assertEquals(mocked_load_full_list.call_count, 1, 'load_full_list() should have been called') + assert mocked_load_full_list.call_count == 1, 'load_full_list() should have been called' # CLEANUP: Remove added attribute from ImageFilenames delattr(ImageFilenames, 'file_path') @@ -133,7 +133,7 @@ class TestImageMediaItem(TestCase): self.media_item.save_new_images_list(image_list, reload_list=False) # THEN: load_full_list() should not have been called - self.assertEquals(mocked_load_full_list.call_count, 0, 'load_full_list() should not have been called') + assert mocked_load_full_list.call_count == 0, 'load_full_list() should not have been called' @patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') def test_save_new_images_list_multiple_images(self, mocked_load_full_list): @@ -148,8 +148,8 @@ class TestImageMediaItem(TestCase): self.media_item.save_new_images_list(image_list, reload_list=False) # THEN: load_full_list() should not have been called - self.assertEquals(self.media_item.manager.save_object.call_count, 3, - 'load_full_list() should have been called three times') + assert self.media_item.manager.save_object.call_count == 3, \ + 'load_full_list() should have been called three times' @patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') def test_save_new_images_list_other_objects_in_list(self, mocked_load_full_list): @@ -201,9 +201,9 @@ class TestImageMediaItem(TestCase): self.media_item.recursively_delete_group(test_group) # THEN: delete_file() should have been called 12 times and manager.delete_object() 7 times. - self.assertEquals(mocked_delete_file.call_count, 12, 'delete_file() should have been called 12 times') - self.assertEquals(self.media_item.manager.delete_object.call_count, 7, - 'manager.delete_object() should be called exactly 7 times') + assert mocked_delete_file.call_count == 12, 'delete_file() should have been called 12 times' + assert self.media_item.manager.delete_object.call_count == 7, \ + 'manager.delete_object() should be called exactly 7 times' # CLEANUP: Remove added attribute from Image Filenames and ImageGroups delattr(ImageFilenames, 'group_id') @@ -258,7 +258,7 @@ class TestImageMediaItem(TestCase): self.media_item.on_delete_click() # THEN: delete_file should have been called twice - self.assertEquals(mocked_delete_file.call_count, 2, 'delete_file() should have been called twice') + assert mocked_delete_file.call_count == 2, 'delete_file() should have been called twice' def test_create_item_from_id(self): """ @@ -280,5 +280,5 @@ class TestImageMediaItem(TestCase): self.assertEqual('test_file_1.jpg', item.text(0)) item_data = item.data(0, QtCore.Qt.UserRole) assert isinstance(item_data, ImageFilenames) - self.assertEqual(1, item_data.id) - self.assertEqual(Path('/', 'tmp', 'test_file_1.jpg'), item_data.file_path) + assert 1 == item_data.id + assert Path('/', 'tmp', 'test_file_1.jpg') == item_data.file_path diff --git a/tests/functional/openlp_plugins/images/test_upgrade.py b/tests/functional/openlp_plugins/images/test_upgrade.py index 471c33609..b1df7d4c3 100644 --- a/tests/functional/openlp_plugins/images/test_upgrade.py +++ b/tests/functional/openlp_plugins/images/test_upgrade.py @@ -80,6 +80,6 @@ class TestImageDBUpgrade(TestCase, TestMixin): 2: Path('/', 'test', 'dir', 'image2.jpg'), 3: Path('/', 'test', 'dir', 'subdir', 'image3.jpg')} - self.assertEqual(len(upgraded_results), 3) + assert len(upgraded_results) == 3 for result in upgraded_results: - self.assertEqual(expected_result_data[result.id], result.file_path) + assert expected_result_data[result.id] == result.file_path diff --git a/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py b/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py index 749229b26..42746f4de 100644 --- a/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py @@ -58,8 +58,8 @@ class TestPresentationController(TestCase): # WHEN: The PresentationController is created # THEN: The name of the presentation controller should be correct - self.assertEqual('PresentationController', self.presentation.name, - 'The name of the presentation controller should be correct') + assert 'PresentationController' == self.presentation.name, \ + 'The name of the presentation controller should be correct' def test_save_titles_and_notes(self): """ @@ -132,9 +132,9 @@ class TestPresentationController(TestCase): result_titles, result_notes = self.document.get_titles_and_notes() # THEN: it should return two empty lists - assert isinstance(result_titles, list, 'result_titles should be of type list') + assert isinstance(result_titles, list), 'result_titles should be of type list' self.assertEqual(len(result_titles), 0, 'there be no titles') - assert isinstance(result_notes, list, 'result_notes should be a list') + assert isinstance(result_notes, list), 'result_notes should be a list' self.assertEqual(len(result_notes), 0, 'but the list should be empty') def test_get_titles_and_notes_with_file_error(self): diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index 5f8b2d6e6..aa16836ef 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -427,7 +427,7 @@ class TestSongSelectImport(TestCase, TestMixin): result = importer.save_song(song_dict) # THEN: The return value should be a Song class and the mocked_db_manager should have been called - assert isinstance(result, Song, 'The returned value should be a Song object') + assert isinstance(result, Song), 'The returned value should be a Song object' mocked_clean_song.assert_called_with(mocked_db_manager, result) self.assertEqual(2, mocked_db_manager.save_object.call_count, 'The save_object() method should have been called twice') @@ -463,7 +463,7 @@ class TestSongSelectImport(TestCase, TestMixin): result = importer.save_song(song_dict) # THEN: The return value should be a Song class and the mocked_db_manager should have been called - assert isinstance(result, Song, 'The returned value should be a Song object') + assert isinstance(result, Song), 'The returned value should be a Song object' mocked_clean_song.assert_called_with(mocked_db_manager, result) self.assertEqual(2, mocked_db_manager.save_object.call_count, 'The save_object() method should have been called twice') @@ -498,7 +498,7 @@ class TestSongSelectImport(TestCase, TestMixin): result = importer.save_song(song_dict) # THEN: The return value should be a Song class and the mocked_db_manager should have been called - assert isinstance(result, Song, 'The returned value should be a Song object') + assert isinstance(result, Song), 'The returned value should be a Song object' mocked_clean_song.assert_called_with(mocked_db_manager, result) self.assertEqual(2, mocked_db_manager.save_object.call_count, 'The save_object() method should have been called twice')