2015-01-08 22:05:32 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2019 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, either version 3 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# 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, see <https://www.gnu.org/licenses/>. #
|
|
|
|
##########################################################################
|
2015-01-08 22:05:32 +00:00
|
|
|
"""
|
|
|
|
Package to test the openlp.core.ui.themeform package.
|
|
|
|
"""
|
2019-05-22 06:47:00 +00:00
|
|
|
from pathlib import Path
|
2015-01-08 22:05:32 +00:00
|
|
|
from unittest import TestCase
|
2017-04-24 05:17:55 +00:00
|
|
|
from unittest.mock import MagicMock, patch
|
2015-01-08 22:05:32 +00:00
|
|
|
|
2018-08-25 14:08:19 +00:00
|
|
|
from openlp.core.ui.themeform import ThemeForm
|
2015-01-08 22:05:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestThemeManager(TestCase):
|
|
|
|
"""
|
|
|
|
Test the functions in the ThemeManager Class
|
|
|
|
"""
|
2017-05-13 07:05:44 +00:00
|
|
|
def setUp(self):
|
2018-08-25 14:08:19 +00:00
|
|
|
with patch('openlp.core.ui.themeform.ThemeForm._setup'):
|
2017-05-13 07:05:44 +00:00
|
|
|
self.instance = ThemeForm(None)
|
2015-01-08 22:05:32 +00:00
|
|
|
|
2017-05-13 07:05:44 +00:00
|
|
|
def test_on_image_path_edit_path_changed(self):
|
2015-01-08 22:05:32 +00:00
|
|
|
"""
|
2017-05-13 07:05:44 +00:00
|
|
|
Test the `image_path_edit.pathChanged` handler
|
2015-01-08 22:05:32 +00:00
|
|
|
"""
|
2017-05-13 07:05:44 +00:00
|
|
|
# GIVEN: An instance of Theme Form
|
|
|
|
with patch.object(self.instance, 'set_background_page_values') as mocked_set_background_page_values:
|
|
|
|
self.instance.theme = MagicMock()
|
2015-01-08 22:05:32 +00:00
|
|
|
|
2017-05-13 07:05:44 +00:00
|
|
|
# WHEN: `on_image_path_edit_path_changed` is clicked
|
2017-08-04 17:40:57 +00:00
|
|
|
self.instance.on_image_path_edit_path_changed(Path('/', 'new', 'pat.h'))
|
2015-01-08 22:05:32 +00:00
|
|
|
|
2017-05-13 07:05:44 +00:00
|
|
|
# THEN: The theme background file should be set and `set_background_page_values` should have been called
|
2017-12-20 21:18:44 +00:00
|
|
|
assert self.instance.theme.background_filename == Path('/', 'new', 'pat.h')
|
2017-05-13 07:05:44 +00:00
|
|
|
mocked_set_background_page_values.assert_called_once_with()
|