From a81cc8292b2c99d5a46b854aeda3dd5d628890a5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 28 Jun 2016 22:39:16 +0100 Subject: [PATCH] fix some tests --- openlp/core/api/http/endpoint/__init__.py | 3 +++ tests/functional/openlp_core_api/test_websockets.py | 7 ++++--- tests/functional/openlp_core_api_http/__init__.py | 0 .../test_error.py | 0 .../{openlp_core_api => openlp_core_api_http}/test_http.py | 6 +++--- 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 tests/functional/openlp_core_api_http/__init__.py rename tests/functional/{openlp_core_api => openlp_core_api_http}/test_error.py (100%) rename tests/functional/{openlp_core_api => openlp_core_api_http}/test_http.py (93%) diff --git a/openlp/core/api/http/endpoint/__init__.py b/openlp/core/api/http/endpoint/__init__.py index 4355416b4..d7a09ab08 100644 --- a/openlp/core/api/http/endpoint/__init__.py +++ b/openlp/core/api/http/endpoint/__init__.py @@ -66,6 +66,9 @@ class Endpoint(object): if not self.template_dir: raise Exception('No template directory specified') path = os.path.abspath(os.path.join(self.template_dir, filename)) + print(path) + print(self.static_dir) + print('/{prefix}/static'.format(prefix=self.url_prefix)) # if self.static_dir: # kwargs['static_url'] = '/{prefix}/static'.format(prefix=self.url_prefix) return Template(filename=path, input_encoding='utf-8').render(**kwargs) diff --git a/tests/functional/openlp_core_api/test_websockets.py b/tests/functional/openlp_core_api/test_websockets.py index 3cb37afe1..892f41d70 100644 --- a/tests/functional/openlp_core_api/test_websockets.py +++ b/tests/functional/openlp_core_api/test_websockets.py @@ -26,7 +26,8 @@ import json from unittest import TestCase from openlp.core.common import Registry, Settings -from openlp.core.api import Poll, WebSocketServer +from openlp.core.api.websockets import WebSocketServer +from openlp.core.api.poll import Poller from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin @@ -52,7 +53,7 @@ class TestWSServer(TestCase, TestMixin): self.build_settings() Settings().extend_default_settings(__default_settings__) Registry().create() - self.poll = Poll() + self.poll = Poller() def tearDown(self): """ @@ -112,7 +113,7 @@ class TestWSServer(TestCase, TestMixin): self.assertFalse(data['results']['isSecure'], 'The isSecure return value should be False') self.assertFalse(data['results']['isAuthorised'], 'The isAuthorised return value should be False') self.assertTrue(data['results']['twelve'], 'The twelve return value should be False') - self.assertEquals(data['results']['version'], 2, 'The version return value should be 2') + self.assertEquals(data['results']['version'], 3, 'The version return value should be 3') self.assertEquals(data['results']['slide'], 5, 'The slide return value should be 5') self.assertEquals(data['results']['service'], 21, 'The version return value should be 21') self.assertEquals(data['results']['item'], '23-34-45', 'The item return value should match 23-34-45') diff --git a/tests/functional/openlp_core_api_http/__init__.py b/tests/functional/openlp_core_api_http/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/openlp_core_api/test_error.py b/tests/functional/openlp_core_api_http/test_error.py similarity index 100% rename from tests/functional/openlp_core_api/test_error.py rename to tests/functional/openlp_core_api_http/test_error.py diff --git a/tests/functional/openlp_core_api/test_http.py b/tests/functional/openlp_core_api_http/test_http.py similarity index 93% rename from tests/functional/openlp_core_api/test_http.py rename to tests/functional/openlp_core_api_http/test_http.py index 0e7ec90ea..5ac2c44ae 100644 --- a/tests/functional/openlp_core_api/test_http.py +++ b/tests/functional/openlp_core_api_http/test_http.py @@ -25,7 +25,7 @@ Functional tests to test the Http Server Class. from unittest import TestCase -from openlp.core.api import HttpServer +from openlp.core.api.http.server import HttpServer from tests.functional import patch @@ -34,8 +34,8 @@ class TestHttpServer(TestCase): """ A test suite to test starting the http server """ - @patch('openlp.core.api.http.HttpThread') - @patch('openlp.core.api.http.QtCore.QThread') + @patch('openlp.core.api.http.server.HttpWorker') + @patch('openlp.core.api.http.server.QtCore.QThread') def test_serverstart(self, mock_qthread, mock_thread): """ Test the starting of the Waitress Server