forked from openlp/openlp
Add some tests, we're up to 52% coverage now!
This commit is contained in:
parent
42523cfa86
commit
8d379e6785
@ -153,7 +153,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
|||||||
Calculate the number of lines on a page by rendering text
|
Calculate the number of lines on a page by rendering text
|
||||||
"""
|
"""
|
||||||
# Do not trigger on start up
|
# Do not trigger on start up
|
||||||
if self.currentPage != self.welcome_page:
|
if self.currentPage() != self.welcome_page:
|
||||||
self.update_theme()
|
self.update_theme()
|
||||||
self.theme_manager.generate_image(self.theme, True)
|
self.theme_manager.generate_image(self.theme, True)
|
||||||
|
|
||||||
|
@ -508,6 +508,30 @@ class TestCheckMediaWorker(TestCase):
|
|||||||
# THEN: The correct values should be set up
|
# THEN: The correct values should be set up
|
||||||
assert worker is not None
|
assert worker is not None
|
||||||
|
|
||||||
|
@patch('openlp.core.ui.media.systemplayer.functools.partial')
|
||||||
|
@patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaContent')
|
||||||
|
def test_start(self, MockQMediaContent, mocked_partial):
|
||||||
|
"""
|
||||||
|
Test the start method
|
||||||
|
"""
|
||||||
|
# GIVEN: A CheckMediaWorker instance
|
||||||
|
worker = CheckMediaWorker('file.ogv')
|
||||||
|
MockQMediaContent.side_effect = lambda x: x
|
||||||
|
mocked_partial.side_effect = lambda x, y: y
|
||||||
|
|
||||||
|
# WHEN: start() is called
|
||||||
|
with patch.object(worker, 'error') as mocked_error, \
|
||||||
|
patch.object(worker, 'mediaStatusChanged') as mocked_status_change, \
|
||||||
|
patch.object(worker, 'setMedia') as mocked_set_media, \
|
||||||
|
patch.object(worker, 'play') as mocked_play:
|
||||||
|
worker.start()
|
||||||
|
|
||||||
|
# THEN: The correct methods should be called
|
||||||
|
mocked_error.connect.assert_called_once_with('error')
|
||||||
|
mocked_status_change.connect.assert_called_once_with('media')
|
||||||
|
mocked_set_media.assert_called_once_with(QtCore.QUrl('file:file.ogv'))
|
||||||
|
mocked_play.assert_called_once_with()
|
||||||
|
|
||||||
def test_signals_media(self):
|
def test_signals_media(self):
|
||||||
"""
|
"""
|
||||||
Test the signals() signal of the CheckMediaWorker class with a "media" origin
|
Test the signals() signal of the CheckMediaWorker class with a "media" origin
|
||||||
|
@ -233,3 +233,39 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
mocked_message_box.critical.assert_called_once_with(
|
mocked_message_box.critical.assert_called_once_with(
|
||||||
first_time_form, 'Network Error', 'There was a network error attempting to connect to retrieve '
|
first_time_form, 'Network Error', 'There was a network error attempting to connect to retrieve '
|
||||||
'initial configuration information', 'OK')
|
'initial configuration information', 'OK')
|
||||||
|
|
||||||
|
@patch('openlp.core.ui.firsttimewizard.Settings')
|
||||||
|
def test_on_projectors_check_box_checked(self, MockSettings):
|
||||||
|
"""
|
||||||
|
Test that the projector panel is shown when the checkbox in the first time wizard is checked
|
||||||
|
"""
|
||||||
|
# GIVEN: A First Time Wizard and a mocked settings object
|
||||||
|
frw = FirstTimeForm(None)
|
||||||
|
mocked_settings = MagicMock()
|
||||||
|
mocked_settings.value.return_value = True
|
||||||
|
MockSettings.return_value = mocked_settings
|
||||||
|
|
||||||
|
# WHEN: on_projectors_check_box_clicked() is called
|
||||||
|
frw.on_projectors_check_box_clicked()
|
||||||
|
|
||||||
|
# THEN: The visibility of the projects panel should have been set
|
||||||
|
mocked_settings.value.assert_called_once_with('projector/show after wizard')
|
||||||
|
mocked_settings.setValue.assert_called_once_with('projector/show after wizard', False)
|
||||||
|
|
||||||
|
@patch('openlp.core.ui.firsttimewizard.Settings')
|
||||||
|
def test_on_projectors_check_box_unchecked(self, MockSettings):
|
||||||
|
"""
|
||||||
|
Test that the projector panel is shown when the checkbox in the first time wizard is checked
|
||||||
|
"""
|
||||||
|
# GIVEN: A First Time Wizard and a mocked settings object
|
||||||
|
frw = FirstTimeForm(None)
|
||||||
|
mocked_settings = MagicMock()
|
||||||
|
mocked_settings.value.return_value = False
|
||||||
|
MockSettings.return_value = mocked_settings
|
||||||
|
|
||||||
|
# WHEN: on_projectors_check_box_clicked() is called
|
||||||
|
frw.on_projectors_check_box_clicked()
|
||||||
|
|
||||||
|
# THEN: The visibility of the projects panel should have been set
|
||||||
|
mocked_settings.value.assert_called_once_with('projector/show after wizard')
|
||||||
|
mocked_settings.setValue.assert_called_once_with('projector/show after wizard', True)
|
||||||
|
49
tests/openlp_core/ui/test_themeform.py
Normal file
49
tests/openlp_core/ui/test_themeform.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# -*- 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 #
|
||||||
|
###############################################################################
|
||||||
|
"""
|
||||||
|
Interface tests to test the ThemeWizard class and related methods.
|
||||||
|
"""
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from openlp.core.common.registry import Registry
|
||||||
|
from openlp.core.ui.themeform import ThemeForm
|
||||||
|
from tests.helpers.testmixin import TestMixin
|
||||||
|
|
||||||
|
|
||||||
|
class TestThemeManager(TestCase, TestMixin):
|
||||||
|
"""
|
||||||
|
Test the functions in the ThemeManager module
|
||||||
|
"""
|
||||||
|
def setUp(self):
|
||||||
|
"""
|
||||||
|
Create the UI
|
||||||
|
"""
|
||||||
|
Registry.create()
|
||||||
|
|
||||||
|
def test_create_theme_wizard(self):
|
||||||
|
"""
|
||||||
|
Test creating a ThemeForm instance
|
||||||
|
"""
|
||||||
|
# GIVEN: A ThemeForm class
|
||||||
|
# WHEN: An object is created
|
||||||
|
# THEN: There should be no problems
|
||||||
|
ThemeForm(None)
|
Loading…
Reference in New Issue
Block a user