From 0cf1cc5587195e5d8985946b758e47ecfcf4f6d1 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Thu, 21 May 2020 22:26:06 +0200 Subject: [PATCH] Fixes from tests --- cps/admin.py | 28 +- cps/gdrive.py | 4 +- cps/helper.py | 2 +- cps/kobo.py | 2 +- cps/web.py | 8 +- cps/worker.py | 1 - test/Calibre-Web TestSummary.html | 998 +++++++----------------------- 7 files changed, 244 insertions(+), 799 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index b5483db1..9d593954 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -522,6 +522,7 @@ def _configuration_gdrive_helper(to_save): def _configuration_oauth_helper(to_save): active_oauths = 0 + reboot_required = False for element in oauthblueprints: if to_save["config_" + str(element['id']) + "_oauth_client_id"] != element['oauth_client_id'] \ or to_save["config_" + str(element['id']) + "_oauth_client_secret"] != element['oauth_client_secret']: @@ -538,6 +539,7 @@ def _configuration_oauth_helper(to_save): {"oauth_client_id": to_save["config_" + str(element['id']) + "_oauth_client_id"], "oauth_client_secret": to_save["config_" + str(element['id']) + "_oauth_client_secret"], "active": element["active"]}) + return reboot_required def _configuration_logfile_helper(to_save, gdriveError): reboot_required = False @@ -552,7 +554,7 @@ def _configuration_logfile_helper(to_save, gdriveError): return reboot_required, _configuration_result(_('Access Logfile Location is not Valid, Please Enter Correct Path'), gdriveError) return reboot_required, None -def _configuration_ldap_helper(gdriveError, to_save): +def _configuration_ldap_helper(to_save, gdriveError): reboot_required = False reboot_required |= _config_string(to_save, "config_ldap_provider_url") reboot_required |= _config_int(to_save, "config_ldap_port") @@ -575,36 +577,36 @@ def _configuration_ldap_helper(gdriveError, to_save): or not config.config_ldap_port \ or not config.config_ldap_dn \ or not config.config_ldap_user_object: - return _configuration_result(_('Please Enter a LDAP Provider, ' + return reboot_required, _configuration_result(_('Please Enter a LDAP Provider, ' 'Port, DN and User Object Identifier'), gdriveError) if config.config_ldap_authentication > constants.LDAP_AUTH_ANONYMOUS: if config.config_ldap_authentication > constants.LDAP_AUTH_UNAUTHENTICATE: if not config.config_ldap_serv_username or not bool(config.config_ldap_serv_password): - return _configuration_result('Please Enter a LDAP Service Account and Password', gdriveError) + return reboot_required, _configuration_result('Please Enter a LDAP Service Account and Password', gdriveError) else: if not config.config_ldap_serv_username: - return _configuration_result('Please Enter a LDAP Service Account', gdriveError) + return reboot_required, _configuration_result('Please Enter a LDAP Service Account', gdriveError) if config.config_ldap_group_object_filter: if config.config_ldap_group_object_filter.count("%s") != 1: - return _configuration_result(_('LDAP Group Object Filter Needs to Have One "%s" Format Identifier'), + return reboot_required, _configuration_result(_('LDAP Group Object Filter Needs to Have One "%s" Format Identifier'), gdriveError) if config.config_ldap_group_object_filter.count("(") != config.config_ldap_group_object_filter.count(")"): - return _configuration_result(_('LDAP Group Object Filter Has Unmatched Parenthesis'), + return reboot_required, _configuration_result(_('LDAP Group Object Filter Has Unmatched Parenthesis'), gdriveError) if config.config_ldap_user_object.count("%s") != 1: - return _configuration_result(_('LDAP User Object Filter needs to Have One "%s" Format Identifier'), + return reboot_required, _configuration_result(_('LDAP User Object Filter needs to Have One "%s" Format Identifier'), gdriveError) if config.config_ldap_user_object.count("(") != config.config_ldap_user_object.count(")"): - return _configuration_result(_('LDAP User Object Filter Has Unmatched Parenthesis'), + return reboot_required, _configuration_result(_('LDAP User Object Filter Has Unmatched Parenthesis'), gdriveError) if config.config_ldap_cert_path and not os.path.isdir(config.config_ldap_cert_path): - return _configuration_result(_('LDAP Certificate Location is not Valid, Please Enter Correct Path'), + return reboot_required, _configuration_result(_('LDAP Certificate Location is not Valid, Please Enter Correct Path'), gdriveError) - return reboot_required + return reboot_required, None def _configuration_update_helper(): @@ -612,7 +614,7 @@ def _configuration_update_helper(): db_change = False to_save = request.form.to_dict() - to_save['config_calibre_dir'] = re.sub('[[\\/]metadata\.db$', '', to_save['config_calibre_dir'], flags=re.IGNORECASE) + to_save['config_calibre_dir'] = re.sub('[\\/]metadata\.db$', '', to_save['config_calibre_dir'], flags=re.IGNORECASE) db_change |= _config_string(to_save, "config_calibre_dir") # Google drive setup @@ -673,7 +675,7 @@ def _configuration_update_helper(): # OAuth configuration if config.config_login_type == constants.LOGIN_OAUTH: - _configuration_oauth_helper(to_save) + reboot_required |= _configuration_oauth_helper(to_save) reboot, message = _configuration_logfile_helper(to_save, gdriveError) if message: @@ -694,7 +696,7 @@ def _configuration_update_helper(): return _configuration_result('%s' % e, gdriveError) if db_change: - if not db.setup_db(config, ub.app_DB_path): + if not calibre_db.setup_db(config, ub.app_DB_path): return _configuration_result(_('DB Location is not Valid, Please Enter Correct Path'), gdriveError) if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK): flash(_(u"DB is not Writeable"), category="warning") diff --git a/cps/gdrive.py b/cps/gdrive.py index 7610795f..aa3743d2 100644 --- a/cps/gdrive.py +++ b/cps/gdrive.py @@ -39,7 +39,7 @@ try: except ImportError: pass -from . import logger, gdriveutils, config, db, ub +from . import logger, gdriveutils, config, ub, calibre_db from .web import admin_required @@ -155,7 +155,7 @@ def on_received_watch_confirmation(): log.info('Setting up new DB') # prevent error on windows, as os.rename does on exisiting files move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath) - db.setup_db(config, ub.app_DB_path) + calibre_db.setup_db(config, ub.app_DB_path) except Exception as e: log.exception(e) updateMetaData() diff --git a/cps/helper.py b/cps/helper.py index 68d1b26e..a0e35c4a 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -879,7 +879,7 @@ def get_cc_columns(filter_config_custom_read=False): for col in tmpcc: if filter_config_custom_read and config.config_read_column and config.config_read_column == col.id: continue - if r and r.match(col.label): + if r and r.match(col.name): continue cc.append(col) diff --git a/cps/kobo.py b/cps/kobo.py index eb543875..cb07a1d2 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -143,7 +143,7 @@ def HandleSyncRequest(): # We reload the book database so that the user get's a fresh view of the library # in case of external changes (e.g: adding a book through Calibre). - db.reconnect_db(config, ub.app_DB_path) + calibre_db.reconnect_db(config, ub.app_DB_path) archived_books = ( ub.session.query(ub.ArchivedBook) diff --git a/cps/web.py b/cps/web.py index 48845a2b..7ac17156 100644 --- a/cps/web.py +++ b/cps/web.py @@ -121,9 +121,9 @@ for ex in default_exceptions: if feature_support['ldap']: # Only way of catching the LDAPException upon logging in with LDAP server down @app.errorhandler(services.ldap.LDAPException) - def handle_LDAP_exception(e): - log.debug('LDAP server not accssible while trying to login to opds feed %s', e) - return error_http(e) + def handle_exception(e): + log.debug('LDAP server not accessible while trying to login to opds feed') + return error_http(FailedDependency()) # @app.errorhandler(InvalidRequestError) #@app.errorhandler(OperationalError) @@ -889,7 +889,7 @@ def ratings_list(): if current_user.check_visibility(constants.SIDEBAR_RATING): entries = calibre_db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'), (db.Ratings.rating / 2).label('name')) \ - .join(calibre_db.books_ratings_link).join(db.Books).filter(common_filters()) \ + .join(db.books_ratings_link).join(db.Books).filter(common_filters()) \ .group_by(text('books_ratings_link.rating')).order_by(db.Ratings.rating).all() return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=list(), title=_(u"Ratings list"), page="ratingslist", data="ratings") diff --git a/cps/worker.py b/cps/worker.py index d08853a0..0efee596 100644 --- a/cps/worker.py +++ b/cps/worker.py @@ -333,7 +333,6 @@ class WorkerThread(threading.Thread): task = {'task':'add_format','id': bookid, 'format': new_format} self.db_queue.put(task) # To Do how to handle error? - print('finished') '''cur_book.data.append(new_format) try: diff --git a/test/Calibre-Web TestSummary.html b/test/Calibre-Web TestSummary.html index af7b6739..c2ae6a27 100755 --- a/test/Calibre-Web TestSummary.html +++ b/test/Calibre-Web TestSummary.html @@ -36,17 +36,17 @@
-

Start Time: 2020-05-21 10:39:39

+

Start Time: 2020-05-21 21:03:04

-

Stop Time: 2020-05-21 11:31:09

+

Stop Time: 2020-05-21 22:00:19

-

Duration: 42:16 min

+

Duration: 48:28 min

@@ -100,13 +100,13 @@ test_anonymous.test_anonymous - 12 - 12 + 13 + 13 0 0 0 - Detail + Detail @@ -114,7 +114,7 @@ -
test_guest_about
+
test_check_locale_guest
PASS @@ -123,7 +123,7 @@ -
test_guest_change_visibility_category
+
test_guest_about
PASS @@ -132,7 +132,7 @@ -
test_guest_change_visibility_format
+
test_guest_change_visibility_category
PASS @@ -141,7 +141,7 @@ -
test_guest_change_visibility_hot
+
test_guest_change_visibility_format
PASS @@ -150,7 +150,7 @@ -
test_guest_change_visibility_language
+
test_guest_change_visibility_hot
PASS @@ -159,7 +159,7 @@ -
test_guest_change_visibility_publisher
+
test_guest_change_visibility_language
PASS @@ -168,7 +168,7 @@ -
test_guest_change_visibility_rated
+
test_guest_change_visibility_publisher
PASS @@ -177,7 +177,7 @@ -
test_guest_change_visibility_rating
+
test_guest_change_visibility_rated
PASS @@ -186,7 +186,7 @@ -
test_guest_change_visibility_series
+
test_guest_change_visibility_rating
PASS @@ -195,7 +195,7 @@ -
test_guest_random_books_available
+
test_guest_change_visibility_series
PASS @@ -204,7 +204,7 @@ -
test_guest_restricted_settings_visibility
+
test_guest_random_books_available
PASS @@ -212,6 +212,15 @@ + +
test_guest_restricted_settings_visibility
+ + PASS + + + + +
test_guest_visibility_sidebar
@@ -319,8 +328,8 @@ test_ebook_convert.test_ebook_convert 11 - 3 - 8 + 11 + 0 0 0 @@ -348,248 +357,74 @@ - +
test_convert_deactivate
- -
- FAIL -
- - - - + PASS - +
test_convert_email
- -
- FAIL -
- - - - + PASS - +
test_convert_failed_and_email
- -
- FAIL -
- - - - + PASS - +
test_convert_only
- -
- FAIL -
- - - - + PASS - +
test_convert_parameter
- -
- FAIL -
- - - - + PASS - +
test_convert_wrong_excecutable
- -
- FAIL -
- - - - + PASS - +
test_email_failed
- -
- FAIL -
- - - - + PASS - +
test_email_only
- -
- FAIL -
- - - - + PASS @@ -1386,9 +1221,9 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye test_ldap.test_ldap_login 9 + 9 + 0 0 - 1 - 8 0 Detail @@ -1397,402 +1232,83 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_LDAP_SSL
- -
- ERROR -
- - - - + PASS - +
test_LDAP_STARTTLS
- -
- ERROR -
- - - - + PASS - +
test_LDAP_fallback_Login
- -
- ERROR -
- - - - + PASS - +
test_LDAP_import
- -
- ERROR -
- - - - + PASS - +
test_LDAP_login
- -
- ERROR -
- - - - + PASS - +
test_invalid_LDAP
- -
- ERROR -
- - - - + PASS - +
test_ldap_about
- -
- FAIL -
- - - - + PASS - +
test_ldap_authentication
- -
- ERROR -
- - - - + PASS - +
test_ldap_opds_download_book
- -
- ERROR -
- - - - - - - - - - - unittest.suite._ErrorHolder - 2 - 0 - 0 - 2 - 0 - - Detail - - - - - - - -
tearDownClass (test_ldap)
- - -
- ERROR -
- - - - - - - - - - -
tearDownClass (test_logging)
- - -
- ERROR -
- - - - + PASS @@ -1801,18 +1317,18 @@ selenium.common.exceptions.NoSuchElementException: Message: Unable to locate ele test_logging.test_logging 6 - 3 + 4 + 1 0 - 2 1 - Detail + Detail - +
test_debug_log
@@ -1821,7 +1337,7 @@ selenium.common.exceptions.NoSuchElementException: Message: Unable to locate ele - +
test_failed_login
@@ -1830,19 +1346,19 @@ selenium.common.exceptions.NoSuchElementException: Message: Unable to locate ele - +
test_failed_register
- SKIP + SKIP
-