Fix progress not showing in the FTW

This commit is contained in:
Raoul Snyman 2018-01-13 16:24:26 -07:00
parent 6263e6654a
commit d758ed257c
5 changed files with 138 additions and 4 deletions

View File

@ -400,9 +400,9 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
if item:
item.setIcon(build_icon(Path(gettempdir(), 'openlp', screenshot)))
def _download_progress(self, count, block_size):
def update_progress(self, count, block_size):
"""
Calculate and display the download progress.
Calculate and display the download progress. This method is called by download_file().
"""
increment = (count * block_size) - self.previous_size
self._increment_progress_bar(None, increment)

View File

@ -63,7 +63,7 @@ class UiFirstTimeWizard(object):
first_time_wizard.setOptions(QtWidgets.QWizard.IndependentPages | QtWidgets.QWizard.NoBackButtonOnStartPage |
QtWidgets.QWizard.NoBackButtonOnLastPage | QtWidgets.QWizard.HaveCustomButton1 |
QtWidgets.QWizard.HaveCustomButton2)
if is_macosx():
if is_macosx(): # pragma: nocover
first_time_wizard.setPixmap(QtWidgets.QWizard.BackgroundPixmap,
QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
first_time_wizard.resize(634, 386)

View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2018 OpenLP Developers #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Functional tests to test the remote index
"""
from unittest.mock import MagicMock, patch
from openlp.core.api.endpoint.remote import index
from openlp.core.api.endpoint.core import TRANSLATED_STRINGS
@patch('openlp.core.api.endpoint.remote.remote_endpoint')
def test_index(mocked_endpoint):
"""
Test the index method of the remote
"""
# GIVEN: A mocked Endpoint
mocked_endpoint.render_template.return_value = 'test template'
# WHEN: index is called
result = index(MagicMock(), 'index')
# THEN: The result should be "test template" and the right methods should have been called
mocked_endpoint.render_template.assert_called_once_with('index.mako', **TRANSLATED_STRINGS)
assert result == 'test template'

View File

@ -23,7 +23,7 @@
Package to test the openlp.core.lib.pluginmanager package.
"""
from unittest import TestCase
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
@ -50,6 +50,32 @@ class TestPluginManager(TestCase):
Registry().register('main_window', self.mocked_main_window)
Registry().register('settings_form', self.mocked_settings_form)
def test_bootstrap_initialise(self):
"""
Test the PluginManager.bootstrap_initialise() method
"""
# GIVEN: A plugin manager with some mocked out methods
manager = PluginManager()
with patch.object(manager, 'find_plugins') as mocked_find_plugins, \
patch.object(manager, 'hook_settings_tabs') as mocked_hook_settings_tabs, \
patch.object(manager, 'hook_media_manager') as mocked_hook_media_manager, \
patch.object(manager, 'hook_import_menu') as mocked_hook_import_menu, \
patch.object(manager, 'hook_export_menu') as mocked_hook_export_menu, \
patch.object(manager, 'hook_tools_menu') as mocked_hook_tools_menu, \
patch.object(manager, 'initialise_plugins') as mocked_initialise_plugins:
# WHEN: bootstrap_initialise() is called
manager.bootstrap_initialise()
# THEN: The hook methods should have been called
mocked_find_plugins.assert_called_with()
mocked_hook_settings_tabs.assert_called_with()
mocked_hook_media_manager.assert_called_with()
mocked_hook_import_menu.assert_called_with()
mocked_hook_export_menu.assert_called_with()
mocked_hook_tools_menu.assert_called_with()
mocked_initialise_plugins.assert_called_with()
def test_hook_media_manager_with_disabled_plugin(self):
"""
Test running the hook_media_manager() method with a disabled plugin

View File

@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2017 OpenLP Developers #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Test the openlp.core.ui package.
"""
from unittest.mock import MagicMock, patch
from openlp.core.ui import SingleColumnTableWidget
def test_single_col_widget_create():
"""
Test creating the SingleColumnTableWidget object
"""
# GIVEN: the SingleColumnTableWidget class
# WHEN: An object is created
widget = SingleColumnTableWidget(None)
# THEN: The object should have 1 column and no visible header
assert widget.columnCount() == 1, 'There should be only 1 column'
assert widget.horizontalHeader().isVisible() is False, 'The horizontal header should not be visible'
@patch('openlp.core.ui.QtWidgets.QTableWidget')
def test_single_col_widget_resize_event(MockQTableWidget):
"""
Test that the resizeEvent method does the right thing
"""
# GIVEN: An instance of a SingleColumnTableWidget and a mocked event
widget = SingleColumnTableWidget(None)
mocked_event = MagicMock()
mocked_event.size.return_value.width.return_value = 10
# WHEN: resizeEvent() is called
with patch.object(widget, 'columnCount') as mocked_column_count, \
patch.object(widget, 'setColumnWidth') as mocked_set_column_width, \
patch.object(widget, 'resizeRowsToContents') as mocked_resize_rows_to_contents:
mocked_column_count.return_value = 1
widget.resizeEvent(mocked_event)
# THEN: The correct calls should have been made
MockQTableWidget.resizeEvent.assert_called_once_with(widget, mocked_event)
mocked_column_count.assert_called_once_with()
mocked_set_column_width.assert_called_once_with(0, 10)
mocked_resize_rows_to_contents.assert_called_once_with()