From 7a47e5cb67e50b733cbe70c6e972d64a9b92a14c Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sun, 15 Jun 2014 22:35:31 +0200 Subject: [PATCH 01/14] fixed bug #719514 ' Themes: and are the same file' Fixes: https://launchpad.net/bugs/719514 --- openlp/core/ui/thememanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index fdd2ea592..6a67605d4 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -650,7 +650,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R finally: if out_file: out_file.close() - if image_from and image_from != image_to: + if image_from and os.path.abspath(image_from) != os.path.abspath(image_to): try: encoding = get_filesystem_encoding() shutil.copyfile(str(image_from).encode(encoding), str(image_to).encode(encoding)) From 376f8f3dc7d0714a876c6ab184638ffc7f0d2db7 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 2 Jul 2014 21:18:18 +0200 Subject: [PATCH 02/14] Added test for thememanager --- .../openlp_core_ui/test_thememanager.py | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/functional/openlp_core_ui/test_thememanager.py diff --git a/tests/functional/openlp_core_ui/test_thememanager.py b/tests/functional/openlp_core_ui/test_thememanager.py new file mode 100644 index 000000000..a0bfbd01e --- /dev/null +++ b/tests/functional/openlp_core_ui/test_thememanager.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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.slidecontroller package. +""" +import os + +from unittest import TestCase + +from openlp.core.common import Registry +from openlp.core.ui import ThemeManager + +from tests.utils.constants import TEST_RESOURCES_PATH +from tests.interfaces import MagicMock, patch + + +class TestThemeManager(TestCase): + + def setUp(self): + """ + Create the UI + """ + Registry.create() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + pass + + def initial_theme_manager_test(self): + """ + Test the initial of theme manager. + """ + # GIVEN: A new service manager instance. + ThemeManager(None) + + # WHEN: the default theme manager is built. + # THEN: The the controller should be registered in the registry. + self.assertNotEqual(Registry().get('theme_manager'), None, 'The base theme manager should be registered') + + def write_theme_test(self): + """ + Test that we don't try to overwrite a theme bacground image with itself + """ + # GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile, + # theme, check_directory_exists and thememanager-attributes. + with patch('builtins.open') as mocked_open, \ + patch('openlp.core.ui.thememanager.shutil.copyfile') as mocked_copyfile, \ + patch('openlp.core.ui.thememanager.check_directory_exists') as mocked_check_directory_exists: + mocked_open.return_value = MagicMock() + theme_manager = ThemeManager(None) + theme_manager.old_background_image = None + theme_manager.generate_and_save_image = MagicMock() + theme_manager.path = '' + mocked_theme = MagicMock() + mocked_theme.theme_name = 'themename' + mocked_theme.extract_formatted_xml = MagicMock() + mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode() + + # WHEN: Calling _write_theme with path to the same image, but the path written slightly different + file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg') + # Do replacement from end of string to avoid problems with path start + file_name2 = file_name1[::-1].replace(os.sep, os.sep + os.sep, 2)[::-1] + theme_manager._write_theme(mocked_theme, file_name1, file_name2) + + # THEN: The mocked_copyfile should not have been called + self.assertFalse(mocked_copyfile.called, 'shutil.copyfile should not be called') From e6f5136708c99f5883d0395e676f17001475a9f7 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 7 Jul 2014 19:22:58 +0200 Subject: [PATCH 03/14] Suggested changes to tests --- .../openlp_core_ui/test_thememanager.py | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_thememanager.py b/tests/functional/openlp_core_ui/test_thememanager.py index a0bfbd01e..496e78aa4 100644 --- a/tests/functional/openlp_core_ui/test_thememanager.py +++ b/tests/functional/openlp_core_ui/test_thememanager.py @@ -44,30 +44,24 @@ class TestThemeManager(TestCase): def setUp(self): """ - Create the UI + Set up the tests """ Registry.create() - def tearDown(self): - """ - Delete all the C++ objects at the end so that we don't have a segfault - """ - pass - def initial_theme_manager_test(self): """ - Test the initial of theme manager. + Test the instantiation of theme manager. """ # GIVEN: A new service manager instance. ThemeManager(None) # WHEN: the default theme manager is built. # THEN: The the controller should be registered in the registry. - self.assertNotEqual(Registry().get('theme_manager'), None, 'The base theme manager should be registered') + self.assertIsNotNone(Registry().get('theme_manager'), 'The base theme manager should be registered') - def write_theme_test(self): + def write_theme_same_image_test(self): """ - Test that we don't try to overwrite a theme bacground image with itself + Test that we don't try to overwrite a theme background image with itself """ # GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile, # theme, check_directory_exists and thememanager-attributes. @@ -92,3 +86,30 @@ class TestThemeManager(TestCase): # THEN: The mocked_copyfile should not have been called self.assertFalse(mocked_copyfile.called, 'shutil.copyfile should not be called') + + def write_theme_diff_images_test(self): + """ + Test that we do overwrite a theme background image when a new is submitted + """ + # GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile, + # theme, check_directory_exists and thememanager-attributes. + with patch('builtins.open') as mocked_open, \ + patch('openlp.core.ui.thememanager.shutil.copyfile') as mocked_copyfile, \ + patch('openlp.core.ui.thememanager.check_directory_exists') as mocked_check_directory_exists: + mocked_open.return_value = MagicMock() + theme_manager = ThemeManager(None) + theme_manager.old_background_image = None + theme_manager.generate_and_save_image = MagicMock() + theme_manager.path = '' + mocked_theme = MagicMock() + mocked_theme.theme_name = 'themename' + mocked_theme.extract_formatted_xml = MagicMock() + mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode() + + # WHEN: Calling _write_theme with path to different images + file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg') + file_name2 = os.path.join(TEST_RESOURCES_PATH, 'church2.jpg') + theme_manager._write_theme(mocked_theme, file_name1, file_name2) + + # THEN: The mocked_copyfile should not have been called + self.assertTrue(mocked_copyfile.called, 'shutil.copyfile should be called') From fdded5adc22d14f2b04df73d5047679b0597e953 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 7 Jul 2014 19:28:27 +0200 Subject: [PATCH 04/14] Fix tag tests --- tests/utils/test_bzr_tags.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index acadbd8c4..393f4ce25 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -50,6 +50,10 @@ TAGS = [ ['1.9.11', '2039'], ['1.9.12', '2063'], ['2.0', '2118'], + ['2.0.1', '?'], + ['2.0.2', '?'], + ['2.0.3', '?'], + ['2.0.4', '?'], ['2.1.0', '2119'] ] From 15ca94554b9309b8d57fa98be3e101bf01821805 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 14 Jul 2014 09:21:36 +0200 Subject: [PATCH 05/14] Updated jenkins script to match tests --- scripts/jenkins_script.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index eeafbfe23..cd6a0c9cf 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -62,11 +62,12 @@ class OpenLPJobs(object): Branch_Pull = 'Branch-01-Pull' Branch_Functional = 'Branch-02-Functional-Tests' Branch_Interface = 'Branch-03-Interface-Tests' - Branch_Windows = 'Branch-04-Windows_Tests' + Branch_Windows_Functional = 'Branch-04a-Windows_Functional_Tests' + Branch_Windows_Interface = 'Branch-04b-Windows_Interface_Tests' Branch_PEP = 'Branch-05a-Code_Analysis' Branch_Coverage = 'Branch-05b-Test_Coverage' - Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows, Branch_PEP, Branch_Coverage] + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, Branch_PEP, Branch_Coverage] class Colour(object): From dc4c9f389b0b1a6bb5e14cfe76e6bdb2b1936fe4 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 14 Jul 2014 09:27:38 +0200 Subject: [PATCH 06/14] pep8 fix --- scripts/jenkins_script.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index cd6a0c9cf..4ee0b3aa2 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -67,7 +67,8 @@ class OpenLPJobs(object): Branch_PEP = 'Branch-05a-Code_Analysis' Branch_Coverage = 'Branch-05b-Test_Coverage' - Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, Branch_PEP, Branch_Coverage] + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, + Branch_PEP, Branch_Coverage] class Colour(object): From 63f08f0c4aba91196866aaeb5a78da99e075ad54 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 18 Aug 2014 20:45:15 +0200 Subject: [PATCH 07/14] Fix ProPresenter import Fixes: https://launchpad.net/bugs/1358418 --- openlp/plugins/songs/lib/importer.py | 2 +- openlp/plugins/songs/lib/importers/__init__.py | 2 +- openlp/plugins/songs/lib/importers/propresenter.py | 11 ++++++++++- openlp/plugins/songs/lib/importers/songimport.py | 9 +++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 0084a74de..9c17e1f67 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -292,7 +292,7 @@ class SongFormat(object): 'class': ProPresenterImport, 'name': 'ProPresenter', 'prefix': 'proPresenter', - 'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter Song Files') + 'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter 4 Song Files') }, SongBeamer: { 'class': SongBeamerImport, diff --git a/openlp/plugins/songs/lib/importers/__init__.py b/openlp/plugins/songs/lib/importers/__init__.py index da302572e..f86a3e95e 100644 --- a/openlp/plugins/songs/lib/importers/__init__.py +++ b/openlp/plugins/songs/lib/importers/__init__.py @@ -27,5 +27,5 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`~openlp.plugins.songs.lib.import` module contains importers for the Songs plugin. +The :mod:`~openlp.plugins.songs.lib.importers` module contains importers for the Songs plugin. """ diff --git a/openlp/plugins/songs/lib/importers/propresenter.py b/openlp/plugins/songs/lib/importers/propresenter.py index 3bf7f9cd8..ca9a2e9c8 100644 --- a/openlp/plugins/songs/lib/importers/propresenter.py +++ b/openlp/plugins/songs/lib/importers/propresenter.py @@ -33,17 +33,20 @@ ProPresenter song files into the current installation database. import os import base64 +import logging from lxml import objectify from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import strip_rtf from .songimport import SongImport +log = logging.getLogger(__name__) + class ProPresenterImport(SongImport): """ The :class:`ProPresenterImport` class provides OpenLP with the - ability to import ProPresenter song files. + ability to import ProPresenter 4 song files. """ def do_import(self): self.import_wizard.progress_bar.setMaximum(len(self.import_source)) @@ -67,9 +70,15 @@ class ProPresenterImport(SongImport): count = 0 for slide in root.slides.RVDisplaySlide: count += 1 + if not hasattr(slide.displayElements, 'RVTextElement'): + log.debug('No text found, may be an image slide') + continue RTFData = slide.displayElements.RVTextElement.get('RTFData') rtf = base64.standard_b64decode(RTFData) words, encoding = strip_rtf(rtf.decode()) self.add_verse(words, "v%d" % count) + # Some songs don't have a title - use the first line as title + if not self.title: + self.title = self.guess_title() if not self.finish(): self.log_error(self.import_source) diff --git a/openlp/plugins/songs/lib/importers/songimport.py b/openlp/plugins/songs/lib/importers/songimport.py index 5382efbe5..14622e978 100644 --- a/openlp/plugins/songs/lib/importers/songimport.py +++ b/openlp/plugins/songs/lib/importers/songimport.py @@ -316,6 +316,15 @@ class SongImport(QtCore.QObject): self.verse_order_list_generated.append(self.verse_order_list_generated[-1]) self.verse_order_list_generated_useful = True + def guess_title(self): + """ + Guess the title from the first verse (to be used when the song has no title information) + :return: The guessed title + """ + if not self.verses: + return '' + return self.verses[0][1].split('\n')[0].strip() + def check_complete(self): """ Check the mandatory fields are entered (i.e. title and a verse) From 0bf256070a898317a88d0cfca8af6ca9aa16c3dd Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 18 Aug 2014 21:04:46 +0200 Subject: [PATCH 08/14] Add test --- .../songs/lib/importers/propresenter.py | 9 ++--- .../plugins/songs/lib/importers/songimport.py | 9 ----- .../songs/test_propresenterimport.py | 2 ++ .../propresentersongs/Vaste Grond.json | 34 +++++++++++++++++++ .../propresentersongs/Vaste Grond.pro4 | 1 + 5 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 tests/resources/propresentersongs/Vaste Grond.json create mode 100644 tests/resources/propresentersongs/Vaste Grond.pro4 diff --git a/openlp/plugins/songs/lib/importers/propresenter.py b/openlp/plugins/songs/lib/importers/propresenter.py index ca9a2e9c8..b0509393b 100644 --- a/openlp/plugins/songs/lib/importers/propresenter.py +++ b/openlp/plugins/songs/lib/importers/propresenter.py @@ -55,11 +55,11 @@ class ProPresenterImport(SongImport): return self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path)) root = objectify.parse(open(file_path, 'rb')).getroot() - self.process_song(root) + self.process_song(root, file_path) - def process_song(self, root): + def process_song(self, root, filename): self.set_defaults() - self.title = root.get('CCLISongTitle') + self.title = os.path.basename(filename).rstrip('.pro4') self.copyright = root.get('CCLICopyrightInfo') self.comments = root.get('notes') self.ccli_number = root.get('CCLILicenseNumber') @@ -77,8 +77,5 @@ class ProPresenterImport(SongImport): rtf = base64.standard_b64decode(RTFData) words, encoding = strip_rtf(rtf.decode()) self.add_verse(words, "v%d" % count) - # Some songs don't have a title - use the first line as title - if not self.title: - self.title = self.guess_title() if not self.finish(): self.log_error(self.import_source) diff --git a/openlp/plugins/songs/lib/importers/songimport.py b/openlp/plugins/songs/lib/importers/songimport.py index 14622e978..5382efbe5 100644 --- a/openlp/plugins/songs/lib/importers/songimport.py +++ b/openlp/plugins/songs/lib/importers/songimport.py @@ -316,15 +316,6 @@ class SongImport(QtCore.QObject): self.verse_order_list_generated.append(self.verse_order_list_generated[-1]) self.verse_order_list_generated_useful = True - def guess_title(self): - """ - Guess the title from the first verse (to be used when the song has no title information) - :return: The guessed title - """ - if not self.verses: - return '' - return self.verses[0][1].split('\n')[0].strip() - def check_complete(self): """ Check the mandatory fields are entered (i.e. title and a verse) diff --git a/tests/functional/openlp_plugins/songs/test_propresenterimport.py b/tests/functional/openlp_plugins/songs/test_propresenterimport.py index 3b79961f9..f3bdcb959 100644 --- a/tests/functional/openlp_plugins/songs/test_propresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_propresenterimport.py @@ -52,3 +52,5 @@ class TestProPresenterFileImport(SongImportTestHelper): """ self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')], self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) + self.file_import([os.path.join(TEST_PATH, 'Vaste Grond.pro4')], + self.load_external_result_data(os.path.join(TEST_PATH, 'Vaste Grond.json'))) diff --git a/tests/resources/propresentersongs/Vaste Grond.json b/tests/resources/propresentersongs/Vaste Grond.json new file mode 100644 index 000000000..f55abd83e --- /dev/null +++ b/tests/resources/propresentersongs/Vaste Grond.json @@ -0,0 +1,34 @@ +{ + "title": "Vaste Grond", + "verse_order_list": [], + "verses": [ + [ + "God voor U is niets onmogelijk\nHoe ongelofelijk\nU heeft alles in de hand", + "v1" + ], + [ + "U bent God en trekt Uw eigen plan\nU bent voor niemand bang\nVoor niets en niemand bang", + "v2" + ], + [ + "U houd me vast en geeft me moed\nOm door te gaan als ik niet durf\nIk wil van U zijn", + "v3" + ], + [ + "U geeft me kracht, en bent de vaste grond\nwaarop ik stevig sta\nik wil van U zijn, voor altijd van U zijn\nO God.", + "v4" + ], + [ + "Grote God, U bent uitzonderlijk\nen ondoorgrondelijk\nU biedt Uw liefde aan", + "v5" + ], + [ + "Wie ben ik, dat U mij ziet staan\nen met mij om wilt gaan?\nIk kan U niet weerstaan", + "v6" + ], + [ + "Onweerstaanbaar,\nonweerstaanbare God", + "v7" + ] + ] +} \ No newline at end of file diff --git a/tests/resources/propresentersongs/Vaste Grond.pro4 b/tests/resources/propresentersongs/Vaste Grond.pro4 new file mode 100644 index 000000000..7abfb593d --- /dev/null +++ b/tests/resources/propresentersongs/Vaste Grond.pro4 @@ -0,0 +1 @@ +<_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"><_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"><_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"><_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"><_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"><_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"><_-RVRect3D-_position x="32.37209" y="29" z="0" width="1074.349" height="818.7442"><_-D-_serializedShadow containerClass="NSMutableDictionary"> \ No newline at end of file From eeeb2b558ee7080fe378bdb496d5f146970a846f Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 18 Aug 2014 21:05:39 +0200 Subject: [PATCH 09/14] PEP8 --- scripts/jenkins_script.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 6c6fdac80..d7c8a3427 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -67,7 +67,8 @@ class OpenLPJobs(object): Branch_PEP = 'Branch-05a-Code_Analysis' Branch_Coverage = 'Branch-05b-Test_Coverage' - Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, Branch_PEP, Branch_Coverage] + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, + Branch_Windows_Interface, Branch_PEP, Branch_Coverage] class Colour(object): From bde55c79f87d911a675f4556379a85ac51aa78b1 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 18 Aug 2014 21:15:23 +0200 Subject: [PATCH 10/14] No newline at end of file... --- tests/resources/propresentersongs/Vaste Grond.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/propresentersongs/Vaste Grond.json b/tests/resources/propresentersongs/Vaste Grond.json index f55abd83e..75ffac7a2 100644 --- a/tests/resources/propresentersongs/Vaste Grond.json +++ b/tests/resources/propresentersongs/Vaste Grond.json @@ -31,4 +31,4 @@ "v7" ] ] -} \ No newline at end of file +} From ce26493dac45976aa2b54aa75d370dcc3e670f3c Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 19 Aug 2014 07:57:54 +0200 Subject: [PATCH 11/14] We only support v4 files --- openlp/plugins/songs/lib/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 9c17e1f67..e9ee2c2f3 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -290,7 +290,7 @@ class SongFormat(object): }, ProPresenter: { 'class': ProPresenterImport, - 'name': 'ProPresenter', + 'name': 'ProPresenter 4', 'prefix': 'proPresenter', 'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter 4 Song Files') }, From 49fca807f4d476fd00b0bf872f24e89932719938 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 21 Aug 2014 14:41:46 +0200 Subject: [PATCH 12/14] deleted file leftover from merge --- .../openlp_core_ui/test_thememanager.py.moved | 115 ------------------ 1 file changed, 115 deletions(-) delete mode 100644 tests/functional/openlp_core_ui/test_thememanager.py.moved diff --git a/tests/functional/openlp_core_ui/test_thememanager.py.moved b/tests/functional/openlp_core_ui/test_thememanager.py.moved deleted file mode 100644 index 496e78aa4..000000000 --- a/tests/functional/openlp_core_ui/test_thememanager.py.moved +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# 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.slidecontroller package. -""" -import os - -from unittest import TestCase - -from openlp.core.common import Registry -from openlp.core.ui import ThemeManager - -from tests.utils.constants import TEST_RESOURCES_PATH -from tests.interfaces import MagicMock, patch - - -class TestThemeManager(TestCase): - - def setUp(self): - """ - Set up the tests - """ - Registry.create() - - def initial_theme_manager_test(self): - """ - Test the instantiation of theme manager. - """ - # GIVEN: A new service manager instance. - ThemeManager(None) - - # WHEN: the default theme manager is built. - # THEN: The the controller should be registered in the registry. - self.assertIsNotNone(Registry().get('theme_manager'), 'The base theme manager should be registered') - - def write_theme_same_image_test(self): - """ - Test that we don't try to overwrite a theme background image with itself - """ - # GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile, - # theme, check_directory_exists and thememanager-attributes. - with patch('builtins.open') as mocked_open, \ - patch('openlp.core.ui.thememanager.shutil.copyfile') as mocked_copyfile, \ - patch('openlp.core.ui.thememanager.check_directory_exists') as mocked_check_directory_exists: - mocked_open.return_value = MagicMock() - theme_manager = ThemeManager(None) - theme_manager.old_background_image = None - theme_manager.generate_and_save_image = MagicMock() - theme_manager.path = '' - mocked_theme = MagicMock() - mocked_theme.theme_name = 'themename' - mocked_theme.extract_formatted_xml = MagicMock() - mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode() - - # WHEN: Calling _write_theme with path to the same image, but the path written slightly different - file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg') - # Do replacement from end of string to avoid problems with path start - file_name2 = file_name1[::-1].replace(os.sep, os.sep + os.sep, 2)[::-1] - theme_manager._write_theme(mocked_theme, file_name1, file_name2) - - # THEN: The mocked_copyfile should not have been called - self.assertFalse(mocked_copyfile.called, 'shutil.copyfile should not be called') - - def write_theme_diff_images_test(self): - """ - Test that we do overwrite a theme background image when a new is submitted - """ - # GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile, - # theme, check_directory_exists and thememanager-attributes. - with patch('builtins.open') as mocked_open, \ - patch('openlp.core.ui.thememanager.shutil.copyfile') as mocked_copyfile, \ - patch('openlp.core.ui.thememanager.check_directory_exists') as mocked_check_directory_exists: - mocked_open.return_value = MagicMock() - theme_manager = ThemeManager(None) - theme_manager.old_background_image = None - theme_manager.generate_and_save_image = MagicMock() - theme_manager.path = '' - mocked_theme = MagicMock() - mocked_theme.theme_name = 'themename' - mocked_theme.extract_formatted_xml = MagicMock() - mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode() - - # WHEN: Calling _write_theme with path to different images - file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg') - file_name2 = os.path.join(TEST_RESOURCES_PATH, 'church2.jpg') - theme_manager._write_theme(mocked_theme, file_name1, file_name2) - - # THEN: The mocked_copyfile should not have been called - self.assertTrue(mocked_copyfile.called, 'shutil.copyfile should be called') From 3a1fda85d5ba63a0a5489c3344e3a78277e9271e Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 21 Aug 2014 14:51:34 +0200 Subject: [PATCH 13/14] Fixed windows test failure by removing special char from filenames --- .../functional/openlp_plugins/songs/test_powerpraiseimport.py | 4 ++-- ...her, mein Gott zu Dir.json => Naher, mein Gott zu Dir.json} | 0 ...äher, mein Gott zu Dir.ppl => Naher, mein Gott zu Dir.ppl} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/resources/powerpraisesongs/{Näher, mein Gott zu Dir.json => Naher, mein Gott zu Dir.json} (100%) rename tests/resources/powerpraisesongs/{Näher, mein Gott zu Dir.ppl => Naher, mein Gott zu Dir.ppl} (100%) diff --git a/tests/functional/openlp_plugins/songs/test_powerpraiseimport.py b/tests/functional/openlp_plugins/songs/test_powerpraiseimport.py index dbe834e1c..e6a2a5194 100644 --- a/tests/functional/openlp_plugins/songs/test_powerpraiseimport.py +++ b/tests/functional/openlp_plugins/songs/test_powerpraiseimport.py @@ -50,7 +50,7 @@ class TestPowerPraiseFileImport(SongImportTestHelper): """ Test that loading a PowerPraise file works correctly """ - self.file_import([os.path.join(TEST_PATH, 'Näher, mein Gott zu Dir.ppl')], - self.load_external_result_data(os.path.join(TEST_PATH, 'Näher, mein Gott zu Dir.json'))) + self.file_import([os.path.join(TEST_PATH, 'Naher, mein Gott zu Dir.ppl')], + self.load_external_result_data(os.path.join(TEST_PATH, 'Naher, mein Gott zu Dir.json'))) self.file_import([os.path.join(TEST_PATH, 'You are so faithful.ppl')], self.load_external_result_data(os.path.join(TEST_PATH, 'You are so faithful.json'))) diff --git a/tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.json b/tests/resources/powerpraisesongs/Naher, mein Gott zu Dir.json similarity index 100% rename from tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.json rename to tests/resources/powerpraisesongs/Naher, mein Gott zu Dir.json diff --git a/tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.ppl b/tests/resources/powerpraisesongs/Naher, mein Gott zu Dir.ppl similarity index 100% rename from tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.ppl rename to tests/resources/powerpraisesongs/Naher, mein Gott zu Dir.ppl From fd4dc4caf7eeec3206f7ab58ac00d19c9592f100 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 21 Aug 2014 15:07:02 +0200 Subject: [PATCH 14/14] Fixed another windows test by properly constructing paths. --- tests/functional/openlp_core_ui/test_thememanager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_thememanager.py b/tests/functional/openlp_core_ui/test_thememanager.py index 3fd15baac..0f3fa8ac4 100644 --- a/tests/functional/openlp_core_ui/test_thememanager.py +++ b/tests/functional/openlp_core_ui/test_thememanager.py @@ -62,12 +62,12 @@ class TestThemeManager(TestCase): zipfile.ZipFile.write = MagicMock() # WHEN: The theme is exported - theme_manager._export_theme('/some/path', 'Default') + theme_manager._export_theme(os.path.join('some', 'path'), 'Default') # THEN: The zipfile should be created at the given path - zipfile.ZipFile.__init__.assert_called_with('/some/path/Default.otz', 'w') + zipfile.ZipFile.__init__.assert_called_with(os.path.join('some', 'path', 'Default.otz'), 'w') zipfile.ZipFile.write.assert_called_with(os.path.join(TEST_RESOURCES_PATH, 'themes', 'Default', 'Default.xml'), - 'Default/Default.xml') + os.path.join('Default', 'Default.xml')) def initial_theme_manager_test(self): """