From a8680a45cadca5bdf5c20c17210ce15842a7437d Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 19 Apr 2022 15:05:41 +0200 Subject: [PATCH] Bugfixes from Testrun Update teststatus --- cps/db.py | 7 +- cps/metadata_provider/amazon.py | 18 +- cps/templates/list.html | 2 +- cps/web.py | 40 +- test/Calibre-Web TestSummary_Linux.html | 2075 +++++++++++++++++------ 5 files changed, 1564 insertions(+), 578 deletions(-) diff --git a/cps/db.py b/cps/db.py index ff392274..68e02b81 100644 --- a/cps/db.py +++ b/cps/db.py @@ -914,7 +914,8 @@ class CalibreDB: .filter(Languages.lang_code == None) .filter(self.common_filters()) .count()) - tags.append([Category(_("None"), "none"), no_lang_count]) + if no_lang_count: + tags.append([Category(_("None"), "none"), no_lang_count]) return sorted(tags, key=lambda x: x[0].name, reverse=reverse_order) else: if not languages: @@ -993,10 +994,12 @@ class Category: name = None id = None count = None + rating = None - def __init__(self, name, cat_id): + def __init__(self, name, cat_id, rating=None): self.name = name self.id = cat_id + self.rating = rating self.count = 1 '''class Count: diff --git a/cps/metadata_provider/amazon.py b/cps/metadata_provider/amazon.py index 7de0d415..da3aed79 100644 --- a/cps/metadata_provider/amazon.py +++ b/cps/metadata_provider/amazon.py @@ -56,13 +56,13 @@ class Amazon(Metadata): self, query: str, generic_cover: str = "", locale: str = "en" ) -> Optional[List[MetaRecord]]: #timer=time() - def inner(link,index) -> tuple[dict,int]: + def inner(link, index) -> [dict, int]: with self.session as session: try: r = session.get(f"https://www.amazon.com/{link}") r.raise_for_status() - except Exception as e: - log.warning(e) + except Exception as ex: + log.warning(ex) return long_soup = BS(r.text, "lxml") #~4sec :/ soup2 = long_soup.find("div", attrs={"cel_widget_id": "dpx-books-ppd_csm_instrumentation_wrapper"}) @@ -126,16 +126,16 @@ class Amazon(Metadata): headers=self.headers) results.raise_for_status() except requests.exceptions.HTTPError as e: - log.error_or_exception(e) - return None + log.error_or_exception(e) + return None except Exception as e: - log.warning(e) - return None + log.warning(e) + return None soup = BS(results.text, 'html.parser') links_list = [next(filter(lambda i: "digital-text" in i["href"], x.findAll("a")))["href"] for x in soup.findAll("div", attrs={"data-component-type": "s-search-result"})] with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: fut = {executor.submit(inner, link, index) for index, link in enumerate(links_list[:5])} - val=list(map(lambda x : x.result() ,concurrent.futures.as_completed(fut))) - result=list(filter(lambda x: x, val)) + val = list(map(lambda x : x.result() ,concurrent.futures.as_completed(fut))) + result = list(filter(lambda x: x, val)) return [x[0] for x in sorted(result, key=itemgetter(1))] #sort by amazons listing order for best relevance diff --git a/cps/templates/list.html b/cps/templates/list.html index ed59661e..a9089823 100644 --- a/cps/templates/list.html +++ b/cps/templates/list.html @@ -29,7 +29,7 @@
{% endif %} -
+
{{entry[1]}}
{% if entry.name %} diff --git a/cps/web.py b/cps/web.py index ae4b12a8..517539f8 100644 --- a/cps/web.py +++ b/cps/web.py @@ -599,17 +599,29 @@ def render_series_books(page, book_id, order): def render_ratings_books(page, book_id, order): - name = calibre_db.session.query(db.Ratings).filter(db.Ratings.id == book_id).first() - entries, random, pagination = calibre_db.fill_indexpage(page, 0, - db.Books, - db.Books.ratings.any(db.Ratings.id == book_id), - [order[0][0]], - True, config.config_read_column) - if name and name.rating <= 10: + if book_id == '-1': + entries, random, pagination = calibre_db.fill_indexpage(page, 0, + db.Books, + db.Books.ratings == None, + [order[0][0]], + True, config.config_read_column, + db.books_series_link, + db.Books.id == db.books_series_link.c.book, + db.Series) + title = _(u"Rating: None") + rating = -1 + else: + name = calibre_db.session.query(db.Ratings).filter(db.Ratings.id == book_id).first() + entries, random, pagination = calibre_db.fill_indexpage(page, 0, + db.Books, + db.Books.ratings.any(db.Ratings.id == book_id), + [order[0][0]], + True, config.config_read_column) + title = _(u"Rating: %(rating)s stars", rating=int(name.rating / 2)) + rating = name.rating + if title and rating <= 10: return render_title_template('index.html', random=random, pagination=pagination, entries=entries, id=book_id, - title=_(u"Rating: %(rating)s stars", rating=int(name.rating / 2)), - page="ratings", - order=order[1]) + title=title, page="ratings", order=order[1]) else: abort(404) @@ -1001,6 +1013,7 @@ def publisher_list(): .count()) if no_publisher_count: entries.append([db.Category(_("None"), "-1"), no_publisher_count]) + entries = sorted(entries, key=lambda x: x[0].name, reverse=not order_no) char_list = generate_char_list(entries) return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=char_list, title=_(u"Publishers"), page="publisherlist", data="publisher", order=order_no) @@ -1030,6 +1043,7 @@ def series_list(): .count()) if no_series_count: entries.append([db.Category(_("None"), "-1"), no_series_count]) + entries = sorted(entries, key=lambda x: x[0].name, reverse=not order_no) return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=char_list, title=_(u"Series"), page="serieslist", data="series", order=order_no) else: @@ -1060,10 +1074,11 @@ def ratings_list(): .group_by(text('books_ratings_link.rating')).order_by(order).all() no_rating_count = (calibre_db.session.query(db.Books) .outerjoin(db.books_ratings_link).outerjoin(db.Ratings) - .filter(db.Ratings.name == None) + .filter(db.Ratings.rating == None) .filter(calibre_db.common_filters()) .count()) - entries.append([db.Category(_("None"), "-1"), no_rating_count]) + entries.append([db.Category(_("None"), "-1", -1), no_rating_count]) + entries = sorted(entries, key=lambda x: x[0].rating, reverse=not order_no) return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=list(), title=_(u"Ratings list"), page="ratingslist", data="ratings", order=order_no) else: @@ -1130,6 +1145,7 @@ def category_list(): .count()) if no_tag_count: entries.append([db.Category(_("None"), "-1"), no_tag_count]) + entries = sorted(entries, key=lambda x: x[0].name, reverse=not order_no) char_list = generate_char_list(entries) return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=char_list, title=_(u"Categories"), page="catlist", data="category", order=order_no) diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 392fdbea..d384225f 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2022-04-03 07:19:10

+

Start Time: 2022-04-18 20:29:19

-

Stop Time: 2022-04-03 12:55:38

+

Stop Time: 2022-04-19 07:55:03

-

Duration: 4h 47 min

+

Duration: 10h 36 min

@@ -102,15 +102,15 @@ - + TestAnonymous - 13 - 13 - 0 - 0 + 18 + 5 + 6 + 7 0 - Detail + Detail @@ -134,11 +134,33 @@ - +
TestAnonymous - test_guest_change_visibility_category
- PASS + +
+ FAIL +
+ + + + @@ -161,20 +183,64 @@ - +
TestAnonymous - test_guest_change_visibility_language
- PASS + +
+ FAIL +
+ + + + - +
TestAnonymous - test_guest_change_visibility_publisher
- PASS + +
+ FAIL +
+ + + + @@ -188,67 +254,368 @@ - +
TestAnonymous - test_guest_change_visibility_rating
- PASS + +
+ ERROR +
+ + + + - + + +
TestAnonymous - test_guest_change_visibility_rating
+ + +
+ ERROR +
+ + + + + + + + +
TestAnonymous - test_guest_change_visibility_series
- PASS + +
+ FAIL +
+ + + + - + + +
TestAnonymous - test_guest_change_visibility_series
+ + +
+ ERROR +
+ + + + + + + + +
TestAnonymous - test_guest_random_books_available
- PASS + +
+ FAIL +
+ + + + - + + +
TestAnonymous - test_guest_random_books_available
+ + +
+ ERROR +
+ + + + + + + + +
TestAnonymous - test_guest_restricted_settings_visibility
- PASS + +
+ ERROR +
+ + + + - + + +
TestAnonymous - test_guest_restricted_settings_visibility
+ + +
+ ERROR +
+ + + + + + + + +
TestAnonymous - test_guest_visibility_sidebar
- PASS + +
+ FAIL +
+ + + + + + + + + + +
TestAnonymous - test_guest_visibility_sidebar
+ + +
+ ERROR +
+ + + + - - TestCli - 9 - 9 + + _ErrorHolder + 1 0 0 + 1 0 - Detail + Detail - + + +
tearDownClass (test_anonymous)
+ + +
+ ERROR +
+ + + + + + + + + + + TestCli + 9 + 4 + 4 + 1 + 0 + + Detail + + + + + +
TestCli - test_already_started
@@ -257,34 +624,121 @@ - +
TestCli - test_bind_to_single_interface
- PASS + +
+ FAIL +
+ + + + - +
TestCli - test_change_password
- PASS + +
+ FAIL +
+ + + + - +
TestCli - test_cli_SSL_files
- PASS + +
+ FAIL +
+ + + + - +
TestCli - test_cli_different_folder
@@ -293,16 +747,46 @@ - +
TestCli - test_cli_different_settings_database
- PASS + +
+ ERROR +
+ + + + - +
TestCli - test_dryrun_update
@@ -311,7 +795,7 @@ - +
TestCli - test_environ_port_setting
@@ -320,11 +804,43 @@ - +
TestCli - test_settingsdb_not_writeable
- PASS + +
+ FAIL +
+ + + + @@ -332,19 +848,28 @@ TestCliGdrivedb - 2 - 2 + 3 + 3 0 0 0 - Detail + Detail - + + +
TestCliGdrivedb - test_cli_gdrive_folder
+ + PASS + + + + +
TestCliGdrivedb - test_cli_gdrive_location
@@ -353,7 +878,7 @@ - +
TestCliGdrivedb - test_gdrive_db_nonwrite
@@ -371,13 +896,13 @@ 0 0 - Detail + Detail - +
TestCoverEditBooks - test_invalid_jpg_hdd
@@ -386,7 +911,7 @@ - +
TestCoverEditBooks - test_upload_jpg
@@ -396,25 +921,45 @@ - + TestDeleteDatabase 1 - 1 0 + 1 0 0 - Detail + Detail - +
TestDeleteDatabase - test_delete_books_in_database
- PASS + +
+ FAIL +
+ + + + @@ -428,13 +973,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertCalibre - test_calibre_log
@@ -443,7 +988,7 @@ - +
TestEbookConvertCalibre - test_convert_deactivate
@@ -452,7 +997,7 @@ - +
TestEbookConvertCalibre - test_convert_email
@@ -461,7 +1006,7 @@ - +
TestEbookConvertCalibre - test_convert_failed_and_email
@@ -470,7 +1015,7 @@ - +
TestEbookConvertCalibre - test_convert_only
@@ -479,7 +1024,7 @@ - +
TestEbookConvertCalibre - test_convert_options
@@ -488,7 +1033,7 @@ - +
TestEbookConvertCalibre - test_convert_parameter
@@ -497,7 +1042,7 @@ - +
TestEbookConvertCalibre - test_convert_wrong_excecutable
@@ -506,7 +1051,7 @@ - +
TestEbookConvertCalibre - test_convert_xss
@@ -515,7 +1060,7 @@ - +
TestEbookConvertCalibre - test_email_failed
@@ -524,7 +1069,7 @@ - +
TestEbookConvertCalibre - test_email_only
@@ -533,7 +1078,7 @@ - +
TestEbookConvertCalibre - test_kindle_send_not_configured
@@ -542,7 +1087,7 @@ - +
TestEbookConvertCalibre - test_ssl_smtp_setup_error
@@ -551,7 +1096,7 @@ - +
TestEbookConvertCalibre - test_starttls_smtp_setup_error
@@ -560,7 +1105,7 @@ - +
TestEbookConvertCalibre - test_user_convert_xss
@@ -578,13 +1123,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertCalibreGDrive - test_convert_email
@@ -593,7 +1138,7 @@ - +
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
@@ -602,7 +1147,7 @@ - +
TestEbookConvertCalibreGDrive - test_convert_only
@@ -611,7 +1156,7 @@ - +
TestEbookConvertCalibreGDrive - test_convert_parameter
@@ -620,7 +1165,7 @@ - +
TestEbookConvertCalibreGDrive - test_email_failed
@@ -629,7 +1174,7 @@ - +
TestEbookConvertCalibreGDrive - test_email_only
@@ -647,13 +1192,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertKepubify - test_convert_deactivate
@@ -662,7 +1207,7 @@ - +
TestEbookConvertKepubify - test_convert_only
@@ -671,7 +1216,7 @@ - +
TestEbookConvertKepubify - test_convert_wrong_excecutable
@@ -689,13 +1234,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertGDriveKepubify - test_convert_deactivate
@@ -704,7 +1249,7 @@ - +
TestEbookConvertGDriveKepubify - test_convert_only
@@ -713,7 +1258,7 @@ - +
TestEbookConvertGDriveKepubify - test_convert_wrong_excecutable
@@ -731,13 +1276,13 @@ 0 1 - Detail + Detail - +
TestEditAdditionalBooks - test_cbz_comicinfo
@@ -746,7 +1291,7 @@ - +
TestEditAdditionalBooks - test_change_upload_formats
@@ -755,7 +1300,7 @@ - +
TestEditAdditionalBooks - test_delete_book
@@ -764,7 +1309,7 @@ - +
TestEditAdditionalBooks - test_delete_role
@@ -773,7 +1318,7 @@ - +
TestEditAdditionalBooks - test_details_popup
@@ -782,7 +1327,7 @@ - +
TestEditAdditionalBooks - test_edit_book_identifier
@@ -791,7 +1336,7 @@ - +
TestEditAdditionalBooks - test_edit_book_identifier_capital
@@ -800,7 +1345,7 @@ - +
TestEditAdditionalBooks - test_edit_book_identifier_standard
@@ -809,7 +1354,7 @@ - +
TestEditAdditionalBooks - test_edit_special_book_identifier
@@ -818,7 +1363,7 @@ - +
TestEditAdditionalBooks - test_title_sort
@@ -827,7 +1372,7 @@ - +
TestEditAdditionalBooks - test_upload_cbz_coverformats
@@ -836,7 +1381,7 @@ - +
TestEditAdditionalBooks - test_upload_edit_role
@@ -845,7 +1390,7 @@ - +
TestEditAdditionalBooks - test_upload_metadata_cbr
@@ -854,7 +1399,7 @@ - +
TestEditAdditionalBooks - test_upload_metadata_cbt
@@ -863,7 +1408,7 @@ - +
TestEditAdditionalBooks - test_xss_author_edit
@@ -872,7 +1417,7 @@ - +
TestEditAdditionalBooks - test_xss_comment_edit
@@ -881,7 +1426,7 @@ - +
TestEditAdditionalBooks - test_xss_custom_comment_edit
@@ -899,13 +1444,13 @@ 0 1 - Detail + Detail - +
TestEditBooks - test_download_book
@@ -914,7 +1459,7 @@ - +
TestEditBooks - test_edit_author
@@ -923,7 +1468,7 @@ - +
TestEditBooks - test_edit_category
@@ -932,7 +1477,7 @@ - +
TestEditBooks - test_edit_comments
@@ -941,7 +1486,7 @@ - +
TestEditBooks - test_edit_custom_bool
@@ -950,7 +1495,7 @@ - +
TestEditBooks - test_edit_custom_categories
@@ -959,7 +1504,7 @@ - +
TestEditBooks - test_edit_custom_comment
@@ -968,7 +1513,7 @@ - +
TestEditBooks - test_edit_custom_date
@@ -977,7 +1522,7 @@ - +
TestEditBooks - test_edit_custom_float
@@ -986,7 +1531,7 @@ - +
TestEditBooks - test_edit_custom_int
@@ -995,7 +1540,7 @@ - +
TestEditBooks - test_edit_custom_rating
@@ -1004,7 +1549,7 @@ - +
TestEditBooks - test_edit_custom_single_select
@@ -1013,7 +1558,7 @@ - +
TestEditBooks - test_edit_custom_text
@@ -1022,7 +1567,7 @@ - +
TestEditBooks - test_edit_language
@@ -1031,7 +1576,7 @@ - +
TestEditBooks - test_edit_publisher
@@ -1040,7 +1585,7 @@ - +
TestEditBooks - test_edit_publishing_date
@@ -1049,7 +1594,7 @@ - +
TestEditBooks - test_edit_rating
@@ -1058,7 +1603,7 @@ - +
TestEditBooks - test_edit_series
@@ -1067,7 +1612,7 @@ - +
TestEditBooks - test_edit_title
@@ -1076,19 +1621,19 @@ - +
TestEditBooks - test_rename_uppercase_lowercase
- SKIP + SKIP
-