2014-03-14 22:08:44 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2016-12-31 11:01:36 +00:00
|
|
|
# Copyright (c) 2008-2017 OpenLP Developers #
|
2014-03-14 22:08:44 +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; 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 #
|
|
|
|
###############################################################################
|
2013-03-14 22:22:18 +00:00
|
|
|
"""
|
|
|
|
Package to test the openlp.plugins.songs.forms.topicsform package.
|
|
|
|
"""
|
|
|
|
from unittest import TestCase
|
|
|
|
|
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
|
2014-03-14 22:08:44 +00:00
|
|
|
from tests.helpers.testmixin import TestMixin
|
2013-03-14 22:22:18 +00:00
|
|
|
|
|
|
|
|
2014-03-14 22:08:44 +00:00
|
|
|
class TestTopicsForm(TestCase, TestMixin):
|
2013-03-14 22:22:18 +00:00
|
|
|
"""
|
|
|
|
Test the TopicsForm class
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
Create the UI
|
|
|
|
"""
|
|
|
|
Registry.create()
|
2014-10-22 20:43:05 +00:00
|
|
|
self.setup_application()
|
2015-11-07 00:49:40 +00:00
|
|
|
self.main_window = QtWidgets.QMainWindow()
|
2013-08-31 18:17:38 +00:00
|
|
|
Registry().register('main_window', self.main_window)
|
2013-03-14 22:22:18 +00:00
|
|
|
self.form = TopicsForm()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
"""
|
|
|
|
Delete all the C++ objects at the end so that we don't have a segfault
|
|
|
|
"""
|
|
|
|
del self.form
|
|
|
|
del self.main_window
|
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_ui_defaults(self):
|
2013-03-14 22:22:18 +00:00
|
|
|
"""
|
|
|
|
Test the TopicsForm defaults are correct
|
|
|
|
"""
|
2017-12-23 09:09:45 +00:00
|
|
|
assert self.form.name_edit.text() == '', 'The first name edit should be empty'
|
2013-03-14 22:22:18 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_get_name_property(self):
|
2013-03-14 22:22:18 +00:00
|
|
|
"""
|
|
|
|
Test that getting the name property on the TopicsForm works correctly
|
|
|
|
"""
|
|
|
|
# GIVEN: A topic name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
topic_name = 'Salvation'
|
2013-03-14 22:22:18 +00:00
|
|
|
|
|
|
|
# WHEN: The name_edit's text is set
|
|
|
|
self.form.name_edit.setText(topic_name)
|
|
|
|
|
|
|
|
# THEN: The name property should have the correct value
|
2017-12-23 09:09:45 +00:00
|
|
|
assert self.form.name == topic_name, 'The name property should be correct'
|
2013-03-14 22:22:18 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_set_name_property(self):
|
2013-03-14 22:22:18 +00:00
|
|
|
"""
|
|
|
|
Test that setting the name property on the TopicsForm works correctly
|
|
|
|
"""
|
|
|
|
# GIVEN: A topic name to set
|
2013-08-31 18:17:38 +00:00
|
|
|
topic_name = 'James'
|
2013-03-14 22:22:18 +00:00
|
|
|
|
|
|
|
# WHEN: The name property is set
|
|
|
|
self.form.name = topic_name
|
|
|
|
|
|
|
|
# THEN: The name_edit should have the correct value
|
2017-12-23 09:09:45 +00:00
|
|
|
assert self.form.name_edit.text() == topic_name, 'The topic name should be set correctly'
|