From 1bcb6415c1c903aefffd494c01d8c7f05726423c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 5 Mar 2017 16:55:58 +0000 Subject: [PATCH] fix tests --- openlp/core/api/poll.py | 1 + .../functional/openlp_core_api/test_deploy.py | 28 +++++++++---------- .../openlp_core_api_http/test_init.py | 13 ++++++++- tests/interfaces/openlp_core_api/__init__.py | 21 ++++++++++++++ 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/openlp/core/api/poll.py b/openlp/core/api/poll.py index 215ee34b9..11407a8e2 100644 --- a/openlp/core/api/poll.py +++ b/openlp/core/api/poll.py @@ -25,6 +25,7 @@ import json from openlp.core.common import RegistryProperties, Settings from openlp.core.common.httputils import get_web_page + class Poller(RegistryProperties): """ Accessed by the web layer to get status type information from the application diff --git a/tests/functional/openlp_core_api/test_deploy.py b/tests/functional/openlp_core_api/test_deploy.py index 3d454698f..c0727159e 100644 --- a/tests/functional/openlp_core_api/test_deploy.py +++ b/tests/functional/openlp_core_api/test_deploy.py @@ -35,28 +35,28 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', class TestRemoteDeploy(TestCase): - ''' + """ Test the Remote plugin deploy functions - ''' + """ def setUp(self): - ''' + """ Setup for tests - ''' + """ self.app_root = mkdtemp() def tearDown(self): - ''' + """ Clean up after tests - ''' + """ shutil.rmtree(self.app_root) @patch('openlp.core.api.deploy.os.path.isfile') @patch('openlp.core.api.deploy.os.mknod') def test_check_for_previous_deployment_false(self, mocked_mknod, mocked_isfile): - ''' + """ Remote Deploy tests - Test when the marker file is missing - ''' + """ # GIVEN: A new setup with no marker file # WHEN: I check for a deployment which does not create the marker file mocked_isfile.return_value = False @@ -70,9 +70,9 @@ class TestRemoteDeploy(TestCase): @patch('openlp.core.api.deploy.os.path.isfile') @patch('openlp.core.api.deploy.os.mknod') def test_check_for_previous_deployment_true(self, mocked_mknod, mocked_isfile): - ''' + """ Remote Deploy tests - Test when the marker file is missing - ''' + """ # GIVEN: A new setup with not market file # WHEN: I check for a deployment which does create the marker file mocked_isfile.return_value = False @@ -87,9 +87,9 @@ class TestRemoteDeploy(TestCase): @patch('openlp.core.api.deploy.os.path.isfile') @patch('openlp.core.api.deploy.os.mknod') def test_check_for_previous_deployment_true(self, mocked_mknod, mocked_isfile): - ''' + """ Remote Deploy tests - Test when the marker file is present - ''' + """ # GIVEN: A new setup with not market file # WHEN: I check for a deployment which does not create the marker file mocked_isfile.return_value = True @@ -103,9 +103,9 @@ class TestRemoteDeploy(TestCase): @patch('openlp.core.api.deploy.open') def test_deploy_zipfile(self, mocked_open): - ''' + """ Remote Deploy tests - test the dummy zip file is processed correctly - ''' + """ # GIVEN: A new downloaded zip file zip_file = os.path.join(TEST_PATH, 'remotes', 'site.zip') app_root = os.path.join(self.app_root, 'site.zip') diff --git a/tests/functional/openlp_core_api_http/test_init.py b/tests/functional/openlp_core_api_http/test_init.py index 59fdfda20..3189c06bf 100644 --- a/tests/functional/openlp_core_api_http/test_init.py +++ b/tests/functional/openlp_core_api_http/test_init.py @@ -25,15 +25,26 @@ Functional tests to test the Http Server Class. from unittest import TestCase +from openlp.core.common import Registry from openlp.core.api.http.server import HttpServer -from tests.functional import patch +from tests.functional import patch, MagicMock class TestHttpServer(TestCase): """ A test suite to test starting the http server """ + + def setUp(self): + """ + Create the UI + """ + Registry().create() + Registry().register('service_list', MagicMock()) + + + @patch('openlp.core.api.http.server.HttpWorker') @patch('openlp.core.api.http.server.QtCore.QThread') def test_serverstart(self, mock_qthread, mock_thread): diff --git a/tests/interfaces/openlp_core_api/__init__.py b/tests/interfaces/openlp_core_api/__init__.py index e69de29bb..12625501f 100644 --- a/tests/interfaces/openlp_core_api/__init__.py +++ b/tests/interfaces/openlp_core_api/__init__.py @@ -0,0 +1,21 @@ +# -*- 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 # +############################################################################### \ No newline at end of file