openlp/tests/functional/openlp_core/ui/test_aboutform.py

77 lines
3.5 KiB
Python
Raw Normal View History

2015-01-11 19:46:41 +00:00
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2019-02-14 15:09:09 +00:00
# Copyright (c) 2008-2019 OpenLP Developers #
2015-01-11 19:46:41 +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 #
###############################################################################
"""
Package to test the openlp.core.ui.firsttimeform package.
"""
2017-01-11 20:03:04 +00:00
import datetime
2015-01-11 19:46:41 +00:00
from unittest import TestCase
from unittest.mock import patch
2015-01-11 19:46:41 +00:00
from openlp.core.ui.aboutform import AboutForm
from tests.helpers.testmixin import TestMixin
class TestFirstTimeForm(TestCase, TestMixin):
2016-12-13 14:55:11 +00:00
@patch('openlp.core.ui.aboutform.webbrowser')
def test_on_volunteer_button_clicked(self, mocked_webbrowser):
2015-01-11 19:46:41 +00:00
"""
Test that clicking on the "Volunteer" button opens a web page.
"""
# GIVEN: A new About dialog and a mocked out webbrowser module
2016-12-13 14:55:11 +00:00
about_form = AboutForm(None)
2015-01-11 19:46:41 +00:00
2016-12-13 14:55:11 +00:00
# WHEN: The "Volunteer" button is "clicked"
about_form.on_volunteer_button_clicked()
2015-01-11 19:46:41 +00:00
2016-12-13 14:55:11 +00:00
# THEN: A web browser is opened
mocked_webbrowser.open_new.assert_called_with('http://openlp.org/en/contribute')
@patch('openlp.core.ui.aboutform.get_version')
def test_about_form_build_number(self, mocked_get_version):
2016-12-13 14:55:11 +00:00
"""
Test that the build number is added to the about form
"""
# GIVEN: A mocked out get_version function
mocked_get_version.return_value = {'version': '3.1.5', 'build': '3000'}
2016-12-13 14:55:11 +00:00
# WHEN: The about form is created
about_form = AboutForm(None)
# THEN: The build number should be in the text
2017-12-20 17:37:58 +00:00
assert 'OpenLP 3.1.5 build 3000' in about_form.about_text_edit.toPlainText(), \
"The build number should be set correctly"
2017-01-11 20:03:04 +00:00
def test_about_form_date(self):
2017-01-11 20:03:04 +00:00
"""
Test that the copyright date is included correctly
"""
2017-01-11 20:15:55 +00:00
# GIVEN: A correct application date
2017-01-11 20:03:04 +00:00
date_string = "2004-%s" % datetime.date.today().year
# WHEN: The about form is created
about_form = AboutForm(None)
license_text = about_form.license_text_edit.toPlainText()
2017-01-11 20:15:55 +00:00
# THEN: The date should be in the text twice.
2017-12-20 17:37:58 +00:00
assert license_text.count(date_string, 0) == 2, "The text string should be added twice to the license string"