Merge lp:openlp for manifest test resources and font fix

This commit is contained in:
Kyle Russell 2018-08-31 13:35:30 -04:00
commit 6dc1c37d59
7 changed files with 176 additions and 3 deletions

View File

@ -7,9 +7,11 @@ recursive-include openlp *.css
recursive-include openlp *.png
recursive-include openlp *.ps
recursive-include openlp *.json
recursive-include openlp *.ttf
recursive-include documentation *
recursive-include resources *
recursive-include scripts *
recursive-include tests/resources *
include copyright.txt
include LICENSE
include README.txt

View File

@ -153,7 +153,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
Calculate the number of lines on a page by rendering text
"""
# Do not trigger on start up
if self.currentPage != self.welcome_page:
if self.currentPage() != self.welcome_page:
self.update_theme()
self.theme_manager.generate_image(self.theme, True)

61
scripts/mp_update.py Normal file
View File

@ -0,0 +1,61 @@
#!/usr/bin/env python2
import sys
import os
from argparse import ArgumentParser
from launchpadlib.credentials import UnencryptedFileCredentialStore
from launchpadlib.launchpad import Launchpad
HERE = os.path.dirname(os.path.abspath(__file__))
def parse_args():
"""
Parse the command line arguments
"""
parser = ArgumentParser()
parser.add_argument('-p', '--merge-proposal', required=True,
help='The main part of the URL to the merge proposal, without the hostname.')
parser.add_argument('-m', '--message', required=True,
help='The comment to add to the merge proposal')
parser.add_argument('-s', '--subject', default=None, help='The subject for the comment')
return parser.parse_args()
def get_merge_proposal(merge_proposal_url):
"""
Get the merge proposal for the ``merge_proposal_url``
"""
lp = Launchpad.login_with('OpenLP CI', 'production', version='devel',
credential_store=UnencryptedFileCredentialStore(os.path.join(HERE, 'launchpadcreds.txt')))
openlp_project = lp.projects['openlp']
merge_proposals = openlp_project.getMergeProposals()
for merge_proposal in merge_proposals:
if str(merge_proposal).endswith(merge_proposal_url):
return merge_proposal
return None
def create_comment(merge_proposal, comment, subject):
"""
Create a comment on the merge proposal
"""
if not subject:
subject = 'Jenkins test update'
merge_proposal.createComment(subject=subject, content=comment)
def main():
"""
Run the thing
"""
args = parse_args()
merge_proposal = get_merge_proposal(args.merge_proposal)
if not merge_proposal:
print('No merge proposal with that URL found')
sys.exit(1)
else:
create_comment(merge_proposal, args.message, args.subject)
if __name__ == '__main__':
main()

View File

@ -99,10 +99,11 @@ try:
if tree_revision == tag_revision:
version_string = tag_version.decode('utf-8')
else:
version_string = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8'))
version_string = '{version}.dev{revision}'.format(version=tag_version.decode('utf-8'),
revision=tree_revision.decode('utf-8'))
ver_file = open(VERSION_FILE, 'w')
ver_file.write(version_string)
except:
except Exception:
ver_file = open(VERSION_FILE, 'r')
version_string = ver_file.read().strip()
finally:

View File

@ -508,6 +508,30 @@ class TestCheckMediaWorker(TestCase):
# THEN: The correct values should be set up
assert worker is not None
@patch('openlp.core.ui.media.systemplayer.functools.partial')
@patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaContent')
def test_start(self, MockQMediaContent, mocked_partial):
"""
Test the start method
"""
# GIVEN: A CheckMediaWorker instance
worker = CheckMediaWorker('file.ogv')
MockQMediaContent.side_effect = lambda x: x
mocked_partial.side_effect = lambda x, y: y
# WHEN: start() is called
with patch.object(worker, 'error') as mocked_error, \
patch.object(worker, 'mediaStatusChanged') as mocked_status_change, \
patch.object(worker, 'setMedia') as mocked_set_media, \
patch.object(worker, 'play') as mocked_play:
worker.start()
# THEN: The correct methods should be called
mocked_error.connect.assert_called_once_with('error')
mocked_status_change.connect.assert_called_once_with('media')
mocked_set_media.assert_called_once_with(QtCore.QUrl('file:file.ogv'))
mocked_play.assert_called_once_with()
def test_signals_media(self):
"""
Test the signals() signal of the CheckMediaWorker class with a "media" origin

View File

@ -233,3 +233,39 @@ class TestFirstTimeForm(TestCase, TestMixin):
mocked_message_box.critical.assert_called_once_with(
first_time_form, 'Network Error', 'There was a network error attempting to connect to retrieve '
'initial configuration information', 'OK')
@patch('openlp.core.ui.firsttimewizard.Settings')
def test_on_projectors_check_box_checked(self, MockSettings):
"""
Test that the projector panel is shown when the checkbox in the first time wizard is checked
"""
# GIVEN: A First Time Wizard and a mocked settings object
frw = FirstTimeForm(None)
mocked_settings = MagicMock()
mocked_settings.value.return_value = True
MockSettings.return_value = mocked_settings
# WHEN: on_projectors_check_box_clicked() is called
frw.on_projectors_check_box_clicked()
# THEN: The visibility of the projects panel should have been set
mocked_settings.value.assert_called_once_with('projector/show after wizard')
mocked_settings.setValue.assert_called_once_with('projector/show after wizard', False)
@patch('openlp.core.ui.firsttimewizard.Settings')
def test_on_projectors_check_box_unchecked(self, MockSettings):
"""
Test that the projector panel is shown when the checkbox in the first time wizard is checked
"""
# GIVEN: A First Time Wizard and a mocked settings object
frw = FirstTimeForm(None)
mocked_settings = MagicMock()
mocked_settings.value.return_value = False
MockSettings.return_value = mocked_settings
# WHEN: on_projectors_check_box_clicked() is called
frw.on_projectors_check_box_clicked()
# THEN: The visibility of the projects panel should have been set
mocked_settings.value.assert_called_once_with('projector/show after wizard')
mocked_settings.setValue.assert_called_once_with('projector/show after wizard', True)

View File

@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2018 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; 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 #
###############################################################################
"""
Interface tests to test the ThemeWizard class and related methods.
"""
from unittest import TestCase
from openlp.core.common.registry import Registry
from openlp.core.ui.themeform import ThemeForm
from tests.helpers.testmixin import TestMixin
class TestThemeManager(TestCase, TestMixin):
"""
Test the functions in the ThemeManager module
"""
def setUp(self):
"""
Create the UI
"""
Registry.create()
def test_create_theme_wizard(self):
"""
Test creating a ThemeForm instance
"""
# GIVEN: A ThemeForm class
# WHEN: An object is created
# THEN: There should be no problems
ThemeForm(None)