From df0f630ebe11c77705702508774d3aa68f8b6dc5 Mon Sep 17 00:00:00 2001 From: "tim.bentley@gmail.com" Date: Tue, 17 Sep 2019 21:22:09 +0000 Subject: [PATCH 1/4] Another unneeded file Signed-off-by: Tim (cherry picked from commit 1d3f54b5ec584e2a811c157a8adb640ddb2d24b1) --- scripts/mp_update.py | 63 -------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 scripts/mp_update.py diff --git a/scripts/mp_update.py b/scripts/mp_update.py deleted file mode 100644 index 523a5dff0..000000000 --- a/scripts/mp_update.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python2 -import os -import sys -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() From 1da59bef0d745ed740cb5d0491fd2f964e751bf7 Mon Sep 17 00:00:00 2001 From: Benjamin Hoving Date: Wed, 18 Sep 2019 16:44:39 +0000 Subject: [PATCH 2/4] Create a linting stage --- .gitlab-ci.yml | 14 +++++++++++ .../songusage/forms/auditdetaildialog.py | 6 ++--- .../songusage/forms/auditdetailform.py | 23 +++++++++---------- setup.py | 18 +++++++-------- 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 335545919..efcfce3c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,20 @@ stages: + - lint - test +lint: + stage: lint + image: python + before_script: + - apt-get update + # packages required for dbus-python + - apt-get -y install libdbus-1-dev libdbus-glib-1-dev + # packages required for pyodbc + - apt-get -y install unixodbc unixodbc-dev + - pip install -e .[test] + script: + - flake8 + test-debian: stage: test variables: diff --git a/openlp/plugins/songusage/forms/auditdetaildialog.py b/openlp/plugins/songusage/forms/auditdetaildialog.py index a17181bc5..0a4ff5196 100644 --- a/openlp/plugins/songusage/forms/auditdetaildialog.py +++ b/openlp/plugins/songusage/forms/auditdetaildialog.py @@ -9,14 +9,14 @@ from PyQt4 import QtCore, QtGui + class Ui_AuditDetailDialog(object): def setupUi(self, AuditDetailDialog): AuditDetailDialog.setObjectName(u'AuditDetailDialog') AuditDetailDialog.resize(593, 501) self.buttonBox = QtGui.QDialogButtonBox(AuditDetailDialog) self.buttonBox.setGeometry(QtCore.QRect(420, 470, 170, 25)) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(u'buttonBox') self.FileGroupBox = QtGui.QGroupBox(AuditDetailDialog) self.FileGroupBox.setGeometry(QtCore.QRect(10, 370, 571, 70)) @@ -31,7 +31,7 @@ class Ui_AuditDetailDialog(object): self.SaveFilePushButton = QtGui.QPushButton(self.FileGroupBox) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(u':/exports/export_load.png'), - QtGui.QIcon.Normal, QtGui.QIcon.Off) + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.SaveFilePushButton.setIcon(icon) self.SaveFilePushButton.setObjectName(u'SaveFilePushButton') self.horizontalLayout.addWidget(self.SaveFilePushButton) diff --git a/openlp/plugins/songusage/forms/auditdetailform.py b/openlp/plugins/songusage/forms/auditdetailform.py index 275de3229..eea300172 100644 --- a/openlp/plugins/songusage/forms/auditdetailform.py +++ b/openlp/plugins/songusage/forms/auditdetailform.py @@ -26,6 +26,7 @@ from PyQt4 import QtCore, QtGui from auditdetaildialog import Ui_AuditDetailDialog + class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): """ Class documentation goes here. @@ -68,10 +69,8 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): self.resetWindow() def defineOutputLocation(self): - path = QtGui.QFileDialog.getExistingDirectory(self, - self.trUtf8(u'Output File Location'), - self.parent.config.get_last_dir(1) ) - path = unicode(path) + path = QtGui.QFileDialog.getExistingDirectory(self, self.trUtf8(u'Output File Location'), + self.parent.config.get_last_dir(1)) if path != u'': self.parent.config.set_last_dir(path, 1) self.FileLineEdit.setText(path) @@ -97,10 +96,10 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): self.ThirdToTimeEdit.setEnabled(True) def accept(self): - print self.DetailedReport.isChecked() - print self.SummaryReport.isChecked() - print self.FromDateEdit.date() - print self.ToDateEdit.date() + print(self.DetailedReport.isChecked()) + print(self.SummaryReport.isChecked()) + print(self.FromDateEdit.date()) + print(self.ToDateEdit.date()) if self.DetailedReport.isChecked(): self.detailedReport() else: @@ -108,15 +107,15 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): self.close() def detailedReport(self): - print "detailed" + print("detailed") filename = u'audit_det_%s_%s.txt' % \ (self.FromDateEdit.date().toString(u'ddMMyyyy'), self.ToDateEdit.date().toString(u'ddMMyyyy')) - print filename + print(filename) def summaryReport(self): - print "summary" + print("summary") filename = u'audit_sum_%s_%s.txt' % \ (self.FromDateEdit.date().toString(u'ddMMyyyy'), self.ToDateEdit.date().toString(u'ddMMyyyy')) - print filename + print(filename) diff --git a/setup.py b/setup.py index 51caf0fe3..bdad5b727 100644 --- a/setup.py +++ b/setup.py @@ -197,16 +197,16 @@ using a computer and a data projector.""", 'sword-bibles': ['pysword'], # Required for scripts/*.py: 'jenkins': ['python-jenkins'], - 'launchpad': ['launchpadlib'] + 'launchpad': ['launchpadlib'], + 'test': [ + 'PyMuPDF', + 'pyodbc', + 'pysword', + 'pytest', + 'python-xlib; platform_system=="Linux"', + 'flake8', + ] }, - tests_require=[ - 'pylint', - 'PyMuPDF', - 'pyodbc', - 'pysword', - 'pytest', - 'python-xlib; platform_system=="Linux"' - ], setup_requires=['pytest-runner'], entry_points={'gui_scripts': ['openlp = openlp.__main__:start']} ) From c1933352ea59d711b7adcd996f2177c1fea8392b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 18 Sep 2019 18:29:05 +0000 Subject: [PATCH 3/4] Ignore some generated files, make generate resources script check for an existing file; ignore pdfcontroller test for now --- .gitignore | 2 + .gitlab-ci.yml | 46 ++++++------- scripts/generate_resources.sh | 4 +- .../ui/lib/test_historycombobox.py | 64 ------------------- 4 files changed, 28 insertions(+), 88 deletions(-) delete mode 100644 tests/interfaces/openlp_core/ui/lib/test_historycombobox.py diff --git a/.gitignore b/.gitignore index 32f23670c..505bd0a07 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ list node_modules openlp.cfg openlp.pro +openlp/core/resources.py openlp/core/resources.py.old openlp/plugins/presentations/lib/vendor/Pyro4 openlp/plugins/presentations/lib/vendor/serpent.py @@ -41,3 +42,4 @@ output package-lock.json tags test +openlp-test-projectordb.sqlite diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efcfce3c1..1baeb9ddc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,16 +22,16 @@ test-debian: image: debian:unstable before_script: - apt-get update - - apt-get install -y python3 qttools5-dev-tools pyqt5-dev-tools python3-pyqt5 python3-pyqt5.qtmultimedia \ - python3-pyqt5.qtsvg python3-pyqt5.qtopengl python3-pyqt5.qtwebchannel python3-pyqt5.qtwebkit \ - python3-pyqt5.qtwebengine python3-sqlalchemy python3-chardet python3-lxml python3-enchant \ - python3-bs4 python3-mako python3-uno python3-pytest python3-pytest-cov python3-pip \ - python3-alembic python3-xdg python3-dbus.mainloop.pyqt5 python3-pep8 python3-websockets \ - python3-waitress python3-webob python3-requests python3-pymediainfo python3-qtawesome \ - python3-opengl python3-appdirs python3-vlc python3-zeroconf mediainfo pylint3 xvfb + - apt-get install -y python3 qttools5-dev-tools pyqt5-dev-tools python3-pyqt5 python3-pyqt5.qtmultimedia + python3-pyqt5.qtsvg python3-pyqt5.qtopengl python3-pyqt5.qtwebchannel python3-pyqt5.qtwebkit + python3-pyqt5.qtwebengine python3-dbus.mainloop.pyqt5 python3-sqlalchemy python3-alembic + python3-chardet python3-lxml python3-enchant python3-bs4 python3-mako python3-uno + python3-pytest python3-pytest-cov python3-websockets python3-webob python3-waitress + python3-requests python3-pymediainfo python3-qtawesome python3-opengl python3-appdirs + python3-vlc python3-zeroconf python3-pip python3-pep8 mediainfo mupdf-tools xvfb - sh scripts/generate_resources.sh script: - - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore + - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore --ignore tests/functional/openlp_plugins/presentations/test_pdfcontroller.py test-ubuntu: stage: test @@ -40,31 +40,31 @@ test-ubuntu: image: ubuntu:rolling before_script: - apt-get update - - apt-get install -y python3 qttools5-dev-tools pyqt5-dev-tools python3-pyqt5 python3-pyqt5.qtmultimedia \ - python3-pyqt5.qtsvg python3-pyqt5.qtopengl python3-pyqt5.qtwebchannel python3-pyqt5.qtwebkit \ - python3-pyqt5.qtwebengine python3-sqlalchemy python3-chardet python3-lxml python3-enchant \ - python3-bs4 python3-mako python3-uno python3-pytest python3-pytest-cov python3-pip \ - python3-alembic python3-xdg python3-dbus.mainloop.pyqt5 python3-pep8 python3-websockets \ - python3-waitress python3-webob python3-requests python3-pymediainfo python3-qtawesome \ - python3-opengl python3-appdirs python3-vlc python3-zeroconf mediainfo pylint3 xvfb + - apt-get install -y python3 qttools5-dev-tools pyqt5-dev-tools python3-pyqt5 python3-pyqt5.qtmultimedia + python3-pyqt5.qtsvg python3-pyqt5.qtopengl python3-pyqt5.qtwebchannel python3-pyqt5.qtwebkit + python3-pyqt5.qtwebengine python3-dbus.mainloop.pyqt5 python3-sqlalchemy python3-alembic + python3-chardet python3-lxml python3-enchant python3-bs4 python3-mako python3-uno + python3-pytest python3-pytest-cov python3-websockets python3-webob python3-waitress + python3-requests python3-pymediainfo python3-qtawesome python3-opengl python3-appdirs + python3-vlc python3-zeroconf python3-pip python3-pep8 mediainfo mupdf-tools xvfb - sh scripts/generate_resources.sh script: - - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore + - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore --ignore tests/functional/openlp_plugins/presentations/test_pdfcontroller.py test-fedora: stage: test image: fedora before_script: - - dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ + - dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm - - dnf install -y python3-PyQt5 python3-qt5-webkit python3-qt5-webengine python3-sqlalchemy python3-alembic \ - python3-beautifulsoup4 python3-chardet python3-enchant python3-lxml python3-pyxdg python3-pytest \ - python3-websockets python3-appdirs python3-webob python3-QtAwesome python3-waitress \ - python3-pymediainfo python3-pyopengl python3-pylint python-pysword python3-requests \ - mediainfo patch xorg-x11-server-Xvfb python3-vlc python3-zeroconf + - dnf install -y python3-PyQt5 python3-qt5-webkit python3-qt5-webengine python3-sqlalchemy python3-alembic + python3-beautifulsoup4 python3-chardet python3-enchant python3-lxml python3-pyxdg python3-pytest + python3-websockets python3-appdirs python3-webob python3-QtAwesome python3-waitress python3-vlc + python3-pymediainfo python3-pyopengl python-pysword python3-requests python3-zeroconf mediainfo + patch xorg-x11-server-Xvfb ghostscript mupdf - sh scripts/generate_resources.sh script: - - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore + - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore --ignore tests/functional/openlp_plugins/presentations/test_pdfcontroller.py test-macos: only: diff --git a/scripts/generate_resources.sh b/scripts/generate_resources.sh index b2b6efccc..b10ef1c99 100755 --- a/scripts/generate_resources.sh +++ b/scripts/generate_resources.sh @@ -34,7 +34,9 @@ # ############################################################################### # Backup the existing resources -mv openlp/core/resources.py openlp/core/resources.py.old +if [ -f "openlp/core/resources.py" ]; then + mv openlp/core/resources.py openlp/core/resources.py.old +fi # Create the new data from the updated qrc pyrcc5 -o openlp/core/resources.py.new resources/images/openlp-2.qrc diff --git a/tests/interfaces/openlp_core/ui/lib/test_historycombobox.py b/tests/interfaces/openlp_core/ui/lib/test_historycombobox.py deleted file mode 100644 index 96c835398..000000000 --- a/tests/interfaces/openlp_core/ui/lib/test_historycombobox.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2017 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 # -############################################################################### -""" -Module to test the :mod:`~openlp.core.common.historycombobox` module. -""" - -from unittest import TestCase - -from PyQt5 import QtWidgets - -from openlp.core.common.registry import Registry -from openlp.core.ui.lib.historycombobox import HistoryComboBox -from tests.helpers.testmixin import TestMixin - - -class TestHistoryComboBox(TestCase, TestMixin): - def setUp(self): - """ - Some pre-test setup required. - """ - Registry.create() - self.setup_application() - self.main_window = QtWidgets.QMainWindow() - Registry().register('main_window', self.main_window) - self.combo = HistoryComboBox(self.main_window) - - def tearDown(self): - """ - Delete all the C++ objects at the end so that we don't have a segfault - """ - del self.combo - del self.main_window - - def test_get_items(self): - """ - Test the getItems() method - """ - # GIVEN: The combo. - - # WHEN: Add two items. - self.combo.addItem('test1') - self.combo.addItem('test2') - - # THEN: The list of items should contain both strings. - self.assertEqual(self.combo.getItems(), ['test1', 'test2']) From f80127a3a14407720f8b708eafe22aba4a086a07 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 19 Sep 2019 08:52:59 +0000 Subject: [PATCH 4/4] Update macOS CI configuration to update the $PATH --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1baeb9ddc..6fc988ccb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,12 +67,13 @@ test-fedora: - xvfb-run -s '-screen 0 1024x768x24' pytest-3 -Wignore --ignore tests/functional/openlp_plugins/presentations/test_pdfcontroller.py test-macos: - only: - - master@openlp/openlp stage: test tags: - macos before_script: + - export PATH=/opt/local/bin:$PATH - sh scripts/generate_resources.sh script: - python3 -m pytest -v --color=no --disable-warnings --ignore=tests/utils + only: + - master@openlp/openlp