From 7ced39594f76073472901fb0d5dbbbf25712cff4 Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Fri, 19 Jan 2018 21:00:56 +0000 Subject: [PATCH] Add test --- openlp/core/ui/servicemanager.py | 2 -- .../openlp_core/ui/test_mainwindow.py | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index bfe0b0a6a..6c3e1ca9b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -580,8 +580,6 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi for file_item in write_list: total_size += file_item.stat().st_size self.log_debug('ServiceManager.save_file - ZIP contents size is %i bytes' % total_size) - - # Number of items + 1 to zip it self.main_window.display_progress_bar(total_size) try: diff --git a/tests/functional/openlp_core/ui/test_mainwindow.py b/tests/functional/openlp_core/ui/test_mainwindow.py index 4ae21e1e8..888ac435d 100644 --- a/tests/functional/openlp_core/ui/test_mainwindow.py +++ b/tests/functional/openlp_core/ui/test_mainwindow.py @@ -242,3 +242,30 @@ class TestMainWindow(TestCase, TestMixin): # THEN: projector_manager_dock.setVisible should had been called once mocked_dock.setVisible.assert_called_once_with(False) + + def test_increment_progress_bar_default_increment(self): + """ + Test that increment_progress_bar increments the progress bar by 1 when called without the `increment` arg. + """ + # GIVEN: A mocked progress bar + with patch.object(self.main_window, 'load_progress_bar', **{'value.return_value': 0}) as mocked_progress_bar: + + # WHEN: Calling increment_progress_bar without the `increment` arg + self.main_window.increment_progress_bar() + + # THEN: The progress bar value should have been incremented by 1 + mocked_progress_bar.setValue.assert_called_once_with(1) + + def test_increment_progress_bar_custom_increment(self): + """ + Test that increment_progress_bar increments the progress bar by the `increment` arg when called with the + `increment` arg with a set value. + """ + # GIVEN: A mocked progress bar + with patch.object(self.main_window, 'load_progress_bar', **{'value.return_value': 0}) as mocked_progress_bar: + + # WHEN: Calling increment_progress_bar with `increment` set to 10 + self.main_window.increment_progress_bar(increment=10) + + # THEN: The progress bar value should have been incremented by 10 + mocked_progress_bar.setValue.assert_called_once_with(10)