openlp/tests/openlp_plugins/songs/forms/test_topicsform.py

75 lines
2.7 KiB
Python
Raw Normal View History

2014-03-14 22:08:44 +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/>. #
##########################################################################
2013-03-14 22:22:18 +00:00
"""
Package to test the openlp.plugins.songs.forms.topicsform package.
"""
2020-03-19 20:04:28 +00:00
import pytest
2013-03-14 22:22:18 +00:00
2015-11-07 00:49:40 +00:00
from PyQt5 import QtWidgets
2013-03-14 22:22:18 +00:00
2017-10-07 07:05:07 +00:00
from openlp.core.common.registry import Registry
2013-03-14 22:22:18 +00:00
from openlp.plugins.songs.forms.topicsform import TopicsForm
@pytest.fixture()
2020-03-19 20:04:28 +00:00
def form(settings):
main_window = QtWidgets.QMainWindow()
Registry().register('main_window', main_window)
frm = TopicsForm()
yield frm
del frm
del main_window
def test_ui_defaults(form):
2013-03-14 22:22:18 +00:00
"""
2020-03-19 20:04:28 +00:00
Test the TopicsForm defaults are correct
2013-03-14 22:22:18 +00:00
"""
2020-03-19 20:04:28 +00:00
assert form.name_edit.text() == '', 'The first name edit should be empty'
2013-03-14 22:22:18 +00:00
2020-03-19 20:04:28 +00:00
def test_get_name_property(form):
"""
Test that getting the name property on the TopicsForm works correctly
"""
# GIVEN: A topic name to set
topic_name = 'Salvation'
2013-03-14 22:22:18 +00:00
2020-03-19 20:04:28 +00:00
# WHEN: The name_edit's text is set
form.name_edit.setText(topic_name)
2013-03-14 22:22:18 +00:00
2020-03-19 20:04:28 +00:00
# THEN: The name property should have the correct value
assert form.name == topic_name, 'The name property should be correct'
2013-03-14 22:22:18 +00:00
2020-03-19 20:04:28 +00:00
def test_set_name_property(form):
"""
Test that setting the name property on the TopicsForm works correctly
"""
# GIVEN: A topic name to set
topic_name = 'James'
2013-03-14 22:22:18 +00:00
2020-03-19 20:04:28 +00:00
# WHEN: The name property is set
form.name = topic_name
2013-03-14 22:22:18 +00:00
2020-03-19 20:04:28 +00:00
# THEN: The name_edit should have the correct value
assert form.name_edit.text() == topic_name, 'The topic name should be set correctly'