From d5ed5cd665faba16ef3229c9aba0577b464042ae Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sat, 12 Dec 2020 15:16:22 +0100 Subject: [PATCH] Fixes from tests --- cps.py | 8 +- cps/admin.py | 4 +- cps/error_handler.py | 25 +- cps/opds.py | 2 +- cps/templates/admin.html | 2 +- test/Calibre-Web TestSummary_Linux.html | 9473 +++++++++++++++++++---- 6 files changed, 8015 insertions(+), 1499 deletions(-) diff --git a/cps.py b/cps.py index 20aa9cac..32e9b43a 100755 --- a/cps.py +++ b/cps.py @@ -41,6 +41,7 @@ from cps.shelf import shelf from cps.admin import admi from cps.gdrive import gdrive from cps.editbooks import editbook +from cps.error_handler import init_errorhandler try: from cps.kobo import kobo, get_kobo_activated @@ -58,14 +59,17 @@ except ImportError: def main(): app = create_app() + + init_errorhandler() + app.register_blueprint(web) app.register_blueprint(opds) app.register_blueprint(jinjia) app.register_blueprint(about) app.register_blueprint(shelf) app.register_blueprint(admi) - if config.config_use_google_drive: - app.register_blueprint(gdrive) + # if config.config_use_google_drive: + app.register_blueprint(gdrive) app.register_blueprint(editbook) if kobo_available: app.register_blueprint(kobo) diff --git a/cps/admin.py b/cps/admin.py index 3f342374..8b3ca247 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -1327,7 +1327,7 @@ def import_ldap_users(): try: new_users = services.ldap.get_group_members(config.config_ldap_group_name) except (services.ldap.LDAPException, TypeError, AttributeError, KeyError) as e: - log.exception(e) + log.debug_or_exception(e) showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e) return json.dumps(showtext) if not new_users: @@ -1355,7 +1355,7 @@ def import_ldap_users(): try: user_data = services.ldap.get_object_details(user=user_identifier, query_filter=query_filter) except AttributeError as e: - log.exception(e) + log.debug_or_exception(e) continue if user_data: user_login_field = extract_dynamic_field_from_filter(user, config.config_ldap_user_object) diff --git a/cps/error_handler.py b/cps/error_handler.py index e2e1638f..e9cb601a 100644 --- a/cps/error_handler.py +++ b/cps/error_handler.py @@ -48,20 +48,21 @@ def internal_error(error): instance=config.config_calibre_web_title ), 500 -# http error handling -for ex in default_exceptions: - if ex < 500: - app.register_error_handler(ex, error_http) - elif ex == 500: - app.register_error_handler(ex, internal_error) +def init_errorhandler(): + # http error handling + for ex in default_exceptions: + if ex < 500: + app.register_error_handler(ex, error_http) + elif ex == 500: + app.register_error_handler(ex, internal_error) -if services.ldap: - # Only way of catching the LDAPException upon logging in with LDAP server down - @app.errorhandler(services.ldap.LDAPException) - def handle_exception(e): - log.debug('LDAP server not accessible while trying to login to opds feed') - return error_http(FailedDependency()) + if services.ldap: + # Only way of catching the LDAPException upon logging in with LDAP server down + @app.errorhandler(services.ldap.LDAPException) + def handle_exception(e): + log.debug('LDAP server not accessible while trying to login to opds feed') + return error_http(FailedDependency()) # @app.errorhandler(InvalidRequestError) diff --git a/cps/opds.py b/cps/opds.py index 7689eacd..1ae7010c 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -28,7 +28,7 @@ from functools import wraps from flask import Blueprint, request, render_template, Response, g, make_response, abort from flask_login import current_user from sqlalchemy.sql.expression import func, text, or_, and_ - +from werkzeug.security import check_password_hash from . import constants, logger, config, db, calibre_db, ub, services, get_locale, isoLanguages from .helper import get_download_link, get_book_cover diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 3fa86722..1ef64157 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -75,7 +75,7 @@ {% endif %} -
{{_('Edit Basic Configuration')}}
+
{{_('Edit E-mail Server Settings')}}
diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 7b5c881b..dde602ab 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2020-12-09 15:21:02

+

Start Time: 2020-12-12 12:19:43

-

Stop Time: 2020-12-09 17:53:34

+

Stop Time: 2020-12-12 14:23:09

-

Duration: 1h 57 min

+

Duration: 1h 33 min

@@ -236,13 +236,13 @@ _ErrorHolder - 1 + 29 0 0 - 1 + 29 0 - Detail + Detail @@ -265,19 +265,13 @@
Traceback (most recent call last):
-  File "/home/matthias/Entwicklung/calibre-web-test/test/test_anonymous.py", line 23, in tearDownClass
-    cls.stop_calibre_web()
-  File "/home/matthias/Entwicklung/calibre-web-test/test/helper_ui.py", line 372, in stop_calibre_web
-    element.click()
-  File "/home/matthias/Entwicklung/calibre-web-test/test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
-    self._execute(Command.CLICK_ELEMENT)
-  File "/home/matthias/Entwicklung/calibre-web-test/test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
-    return self._parent.execute(command, params)
-  File "/home/matthias/Entwicklung/calibre-web-test/test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
-    self.error_handler.check_response(response)
-  File "/home/matthias/Entwicklung/calibre-web-test/test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
-    raise exception_class(message, screen, stacktrace)
-selenium.common.exceptions.ElementNotInteractableException: Message: Element 
+ File "/home/matthias/Entwicklung/calibre-web-test/test/test_anonymous.py", line 27, in tearDownClass + save_logfiles(cls, cls.__name__) + File "/home/matthias/Entwicklung/calibre-web-test/test/helper_func.py", line 352, in save_logfiles + inst.assertFalse(result,"Exception in File {}".format(file)) + File "/usr/lib/python3.8/unittest/case.py", line 758, in assertFalse + msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr)) +AttributeError: 'bool' object has no attribute '_formatMessage'
@@ -286,51 +280,64 @@ selenium.common.exceptions.ElementNotInteractableException: Message: Element - - - - TestCli - 7 - 3 - 2 - 1 - 1 - - Detail - - - - - + -
TestCli - test_already_started
+
tearDownClass (test_cli)
+ + +
+ ERROR +
+ + + - PASS - + -
TestCli - test_bind_to_single_interface
+
tearDownClass (test_cover_edit_books)
- FAIL + ERROR
-