From fa4120a4bd89048e23e75996d00a39a0391a3592 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 18 Mar 2014 21:58:52 +0100 Subject: [PATCH] Small test fixes --- openlp/plugins/presentations/lib/ppinterface.py | 4 ++-- .../plugins/presentations/lib/pptviewcontroller.py | 8 ++++---- .../openlp_core_common/test_applocation.py | 6 +++--- .../presentations/test_impresscontroller.py | 4 ++-- .../presentations/test_powerpointcontroller.py | 4 ++-- .../presentations/test_powerpointviewercontroller.py | 12 ++++++++---- .../presentations/test_pptviewcontroller.py | 4 ++-- .../functional/openlp_plugins/remotes/test_router.py | 3 +-- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/openlp/plugins/presentations/lib/ppinterface.py b/openlp/plugins/presentations/lib/ppinterface.py index 6de119c20..342ce9d5d 100644 --- a/openlp/plugins/presentations/lib/ppinterface.py +++ b/openlp/plugins/presentations/lib/ppinterface.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# 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, # diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 8f1d463d4..3b03e7991 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -129,14 +129,14 @@ class PptviewDocument(PresentationDocument): temp_folder = self.get_temp_folder() size = ScreenList().current['size'] rect = RECT(size.x(), size.y(), size.right(), size.bottom()) - file_path = os.path.normpath(self.file_path) + self.file_path = os.path.normpath(self.file_path) preview_path = os.path.join(temp_folder, 'slide') # Ensure that the paths are null terminated - file_path = file_path.encode('utf-16-le') + b'\0' + self.file_path = self.file_path.encode('utf-16-le') + b'\0' preview_path = preview_path.encode('utf-16-le') + b'\0' if not os.path.isdir(temp_folder): os.makedirs(temp_folder) - self.ppt_id = self.controller.process.OpenPPT(file_path, None, rect, preview_path) + self.ppt_id = self.controller.process.OpenPPT(self.file_path, None, rect, preview_path) if self.ppt_id >= 0: self.create_thumbnails() self.stop_presentation() @@ -166,7 +166,7 @@ class PptviewDocument(PresentationDocument): """ titles = None notes = None - filename = os.path.normpath(self.filepath) + filename = os.path.normpath(self.file_path) # let's make sure we have a valid zipped presentation if os.path.exists(filename) and zipfile.is_zipfile(filename): namespaces = {"p": "http://schemas.openxmlformats.org/presentationml/2006/main", diff --git a/tests/functional/openlp_core_common/test_applocation.py b/tests/functional/openlp_core_common/test_applocation.py index 8bac4abbf..908f6bcb4 100644 --- a/tests/functional/openlp_core_common/test_applocation.py +++ b/tests/functional/openlp_core_common/test_applocation.py @@ -162,9 +162,9 @@ class TestAppLocation(TestCase): patch('openlp.core.common.applocation.os.path.abspath') as mocked_abspath, \ patch('openlp.core.common.applocation.os.path.split') as mocked_split, \ patch('openlp.core.common.applocation.sys') as mocked_sys: - mocked_abspath.return_value = 'plugins/dir' + mocked_abspath.return_value = os.path.join('plugins','dir') mocked_split.return_value = ['openlp'] - mocked_get_frozen_path.return_value = 'plugins/dir' + mocked_get_frozen_path.return_value = os.path.join('plugins','dir') mocked_sys.frozen = 1 mocked_sys.argv = ['openlp'] @@ -172,7 +172,7 @@ class TestAppLocation(TestCase): directory = AppLocation.get_directory(AppLocation.PluginsDir) # THEN: The correct directory should be returned - self.assertEqual('plugins/dir', directory, 'Directory should be "plugins/dir"') + self.assertEqual(os.path.join('plugins','dir'), directory, 'Directory should be "plugins/dir"') def get_frozen_path_in_unfrozen_app_test(self): """ diff --git a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py index 5679c68d2..e86bcf6aa 100644 --- a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# 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, # diff --git a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py index cd68d572d..71b076cba 100644 --- a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# 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, # diff --git a/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py b/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py index c538920bb..0cde8fcb2 100644 --- a/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# 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, # @@ -29,8 +29,12 @@ """ Functional tests to test the PptviewController class and related methods. """ -from unittest import TestCase +from unittest import TestCase, SkipTest import os + +if os.name != 'nt': + raise SkipTest('Not Windows, skipping test') + from mock import MagicMock, patch, mock_open from openlp.plugins.presentations.lib.pptviewcontroller import PptviewController, PptviewDocument @@ -144,4 +148,4 @@ class TestLibModule(TestCase): # THEN: self.doc.save_titles_and_notes.assert_called_once_with(None, None) self.assertEqual(mocked_is_zf.call_count, 1, 'is_zipfile should have been called once') - \ No newline at end of file + diff --git a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py index 5f25c4d3a..716d3f622 100644 --- a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# 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, # diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 611df37aa..ef4be045d 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -36,8 +36,7 @@ from tempfile import mkstemp from PyQt4 import QtGui -from openlp.core.lib import Registry -from openlp.core.common import Settings +from openlp.core.common import Settings, Registry from openlp.plugins.remotes.lib.httpserver import HttpRouter from urllib.parse import urlparse from tests.functional import MagicMock, patch, mock_open