From 25d74260ce72f659edb5a6504d29b684f793e79b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 30 Mar 2013 06:56:28 +0000 Subject: [PATCH] Add tests for the server --- openlp/plugins/bibles/lib/http.py | 3 + openlp/plugins/remotes/lib/httpserver.py | 14 +- openlp/plugins/remotes/remoteplugin.py | 2 +- .../openlp_core_lib/test_uistrings.py | 1 + tests/interfaces/openlp_plugins/__init__.pyc | Bin 184 -> 0 bytes .../openlp_plugins/remotes/test_server.py | 120 ++++++++++++++++++ 6 files changed, 132 insertions(+), 8 deletions(-) delete mode 100644 tests/interfaces/openlp_plugins/__init__.pyc create mode 100644 tests/interfaces/openlp_plugins/remotes/test_server.py diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index b01377a05..736727e20 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -55,6 +55,7 @@ UGLY_CHARS = { log = logging.getLogger(__name__) + class BGExtract(object): """ Extract verses from BibleGateway @@ -671,6 +672,7 @@ class HTTPBible(BibleDB): application = property(_get_application) + def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None, cleaner=None): """ @@ -715,6 +717,7 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, Registry().get(u'application').process_events() return soup + def send_error_message(error_type): """ Send a standard error message informing the user of an issue. diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 51490bb38..0489428ac 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -158,12 +158,12 @@ class HttpServer(object): 'tools.auth.on': True } - def __init__(self, plugin): + def __init__(self): """ Initialise the http server, and start the server. """ log.debug(u'Initialise httpserver') - self.plugin = plugin + self.settings_section = u'remotes' self.router = HttpRouter() def start_server(self): @@ -187,17 +187,17 @@ class HttpServer(object): """ Define the configuration of the server. """ - if Settings().value(self.plugin.settings_section + u'/https enabled'): - port = Settings().value(self.plugin.settings_section + u'/https port') - address = Settings().value(self.plugin.settings_section + u'/ip address') + if Settings().value(self.settings_section + u'/https enabled'): + port = Settings().value(self.settings_section + u'/https port') + address = Settings().value(self.settings_section + u'/ip address') local_data = AppLocation.get_directory(AppLocation.DataDir) cherrypy.config.update({u'server.socket_host': str(address), u'server.socket_port': port, u'server.ssl_certificate': os.path.join(local_data, u'remotes', u'openlp.crt'), u'server.ssl_private_key': os.path.join(local_data, u'remotes', u'openlp.key')}) else: - port = Settings().value(self.plugin.settings_section + u'/port') - address = Settings().value(self.plugin.settings_section + u'/ip address') + port = Settings().value(self.settings_section + u'/port') + address = Settings().value(self.settings_section + u'/ip address') cherrypy.config.update({u'server.socket_host': str(address)}) cherrypy.config.update({u'server.socket_port': port}) cherrypy.config.update({u'environment': u'embedded'}) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index fd2906feb..f443fbda4 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -67,7 +67,7 @@ class RemotesPlugin(Plugin): """ log.debug(u'initialise') Plugin.initialise(self) - self.server = HttpServer(self) + self.server = HttpServer() self.server.start_server() def finalise(self): diff --git a/tests/functional/openlp_core_lib/test_uistrings.py b/tests/functional/openlp_core_lib/test_uistrings.py index 3351657d1..0070533db 100644 --- a/tests/functional/openlp_core_lib/test_uistrings.py +++ b/tests/functional/openlp_core_lib/test_uistrings.py @@ -6,6 +6,7 @@ from unittest import TestCase from openlp.core.lib import UiStrings + class TestUiStrings(TestCase): def check_same_instance_test(self): diff --git a/tests/interfaces/openlp_plugins/__init__.pyc b/tests/interfaces/openlp_plugins/__init__.pyc deleted file mode 100644 index 0d24c9eff54ac7d86f14523ef46194c4bbc24cad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmZ9GO$q`r423JY5W#!QX3Pa-@BpGC9-x#qGe-JH(*ZrLhY(zw0apgz3w(L-vV3nh zpI3LW>NgA72NAEtoKn|jCZ|SB{TUl!a7zKfL|4!-^d;TVR)%xNc