2016-03-29 15:45:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
2022-02-01 10:10:57 +00:00
|
|
|
# Copyright (c) 2008-2022 OpenLP Developers #
|
2019-04-13 13:00:22 +00:00
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# 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/>. #
|
|
|
|
##########################################################################
|
2016-03-29 15:45:59 +00:00
|
|
|
"""
|
|
|
|
Package to test the openlp.core.ui.ThemeTab package.
|
|
|
|
"""
|
2017-04-24 05:17:55 +00:00
|
|
|
from unittest.mock import MagicMock
|
2016-03-29 15:45:59 +00:00
|
|
|
|
2017-10-07 07:05:07 +00:00
|
|
|
from openlp.core.common.registry import Registry
|
2016-03-29 15:45:59 +00:00
|
|
|
from openlp.core.ui.settingsform import SettingsForm
|
2017-12-28 08:22:55 +00:00
|
|
|
from openlp.core.ui.themestab import ThemesTab
|
2016-03-29 15:45:59 +00:00
|
|
|
|
|
|
|
|
2020-02-09 20:24:05 +00:00
|
|
|
def test_save_triggers_processes_true(mock_settings):
|
|
|
|
"""
|
|
|
|
Test that the global theme event is triggered when the tab is visited.
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Advanced Tab
|
|
|
|
settings_form = SettingsForm(None)
|
|
|
|
themes_tab = ThemesTab(settings_form)
|
|
|
|
Registry().register('renderer', MagicMock())
|
|
|
|
themes_tab.tab_visited = True
|
|
|
|
# WHEN: I change search as type check box
|
|
|
|
themes_tab.save()
|
2016-03-29 15:45:59 +00:00
|
|
|
|
2020-02-09 20:24:05 +00:00
|
|
|
# THEN: we should have two post save processed to run
|
|
|
|
assert 1 == len(settings_form.processes), 'One post save processes should be created'
|
2016-03-29 15:45:59 +00:00
|
|
|
|
|
|
|
|
2020-02-09 20:24:05 +00:00
|
|
|
def test_save_triggers_processes_false(mock_settings):
|
|
|
|
"""
|
|
|
|
Test that the global theme event is not triggered when the tab is not visited.
|
|
|
|
"""
|
|
|
|
# GIVEN: A new Advanced Tab
|
|
|
|
settings_form = SettingsForm(None)
|
|
|
|
themes_tab = ThemesTab(settings_form)
|
|
|
|
Registry().register('renderer', MagicMock())
|
|
|
|
themes_tab.tab_visited = False
|
|
|
|
# WHEN: I change search as type check box
|
|
|
|
themes_tab.save()
|
2016-03-29 15:45:59 +00:00
|
|
|
|
2020-02-09 20:24:05 +00:00
|
|
|
# THEN: we should have two post save processed to run
|
|
|
|
assert 0 == len(settings_form.processes), 'No post save processes should be created'
|