fix tests

This commit is contained in:
Tim Bentley 2017-03-05 16:55:58 +00:00
parent 9c3195d166
commit 1bcb6415c1
4 changed files with 48 additions and 15 deletions

View File

@ -25,6 +25,7 @@ import json
from openlp.core.common import RegistryProperties, Settings from openlp.core.common import RegistryProperties, Settings
from openlp.core.common.httputils import get_web_page from openlp.core.common.httputils import get_web_page
class Poller(RegistryProperties): class Poller(RegistryProperties):
""" """
Accessed by the web layer to get status type information from the application Accessed by the web layer to get status type information from the application

View File

@ -35,28 +35,28 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..',
class TestRemoteDeploy(TestCase): class TestRemoteDeploy(TestCase):
''' """
Test the Remote plugin deploy functions Test the Remote plugin deploy functions
''' """
def setUp(self): def setUp(self):
''' """
Setup for tests Setup for tests
''' """
self.app_root = mkdtemp() self.app_root = mkdtemp()
def tearDown(self): def tearDown(self):
''' """
Clean up after tests Clean up after tests
''' """
shutil.rmtree(self.app_root) shutil.rmtree(self.app_root)
@patch('openlp.core.api.deploy.os.path.isfile') @patch('openlp.core.api.deploy.os.path.isfile')
@patch('openlp.core.api.deploy.os.mknod') @patch('openlp.core.api.deploy.os.mknod')
def test_check_for_previous_deployment_false(self, mocked_mknod, mocked_isfile): def test_check_for_previous_deployment_false(self, mocked_mknod, mocked_isfile):
''' """
Remote Deploy tests - Test when the marker file is missing Remote Deploy tests - Test when the marker file is missing
''' """
# GIVEN: A new setup with no marker file # GIVEN: A new setup with no marker file
# WHEN: I check for a deployment which does not create the marker file # WHEN: I check for a deployment which does not create the marker file
mocked_isfile.return_value = False 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.path.isfile')
@patch('openlp.core.api.deploy.os.mknod') @patch('openlp.core.api.deploy.os.mknod')
def test_check_for_previous_deployment_true(self, mocked_mknod, mocked_isfile): def test_check_for_previous_deployment_true(self, mocked_mknod, mocked_isfile):
''' """
Remote Deploy tests - Test when the marker file is missing Remote Deploy tests - Test when the marker file is missing
''' """
# GIVEN: A new setup with not market file # GIVEN: A new setup with not market file
# WHEN: I check for a deployment which does create the marker file # WHEN: I check for a deployment which does create the marker file
mocked_isfile.return_value = False 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.path.isfile')
@patch('openlp.core.api.deploy.os.mknod') @patch('openlp.core.api.deploy.os.mknod')
def test_check_for_previous_deployment_true(self, mocked_mknod, mocked_isfile): def test_check_for_previous_deployment_true(self, mocked_mknod, mocked_isfile):
''' """
Remote Deploy tests - Test when the marker file is present Remote Deploy tests - Test when the marker file is present
''' """
# GIVEN: A new setup with not market file # GIVEN: A new setup with not market file
# WHEN: I check for a deployment which does not create the marker file # WHEN: I check for a deployment which does not create the marker file
mocked_isfile.return_value = True mocked_isfile.return_value = True
@ -103,9 +103,9 @@ class TestRemoteDeploy(TestCase):
@patch('openlp.core.api.deploy.open') @patch('openlp.core.api.deploy.open')
def test_deploy_zipfile(self, mocked_open): def test_deploy_zipfile(self, mocked_open):
''' """
Remote Deploy tests - test the dummy zip file is processed correctly Remote Deploy tests - test the dummy zip file is processed correctly
''' """
# GIVEN: A new downloaded zip file # GIVEN: A new downloaded zip file
zip_file = os.path.join(TEST_PATH, 'remotes', 'site.zip') zip_file = os.path.join(TEST_PATH, 'remotes', 'site.zip')
app_root = os.path.join(self.app_root, 'site.zip') app_root = os.path.join(self.app_root, 'site.zip')

View File

@ -25,15 +25,26 @@ Functional tests to test the Http Server Class.
from unittest import TestCase from unittest import TestCase
from openlp.core.common import Registry
from openlp.core.api.http.server import HttpServer from openlp.core.api.http.server import HttpServer
from tests.functional import patch from tests.functional import patch, MagicMock
class TestHttpServer(TestCase): class TestHttpServer(TestCase):
""" """
A test suite to test starting the http server 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.HttpWorker')
@patch('openlp.core.api.http.server.QtCore.QThread') @patch('openlp.core.api.http.server.QtCore.QThread')
def test_serverstart(self, mock_qthread, mock_thread): def test_serverstart(self, mock_qthread, mock_thread):

View File

@ -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 #
###############################################################################