1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-23 18:17:24 +00:00

Bugfixes from testrun

This commit is contained in:
Ozzie Isaacs 2022-01-26 18:11:42 +01:00
parent baf32f9045
commit 6339d25af0
6 changed files with 58 additions and 56 deletions

View File

@ -809,7 +809,8 @@ def edit_book(book_id):
if "cover_url" in to_save: if "cover_url" in to_save:
if to_save["cover_url"]: if to_save["cover_url"]:
if not current_user.role_upload(): if not current_user.role_upload():
return "", (403) calibre_db.session.rollback()
return "", 403
if to_save["cover_url"].endswith('/static/generic_cover.jpg'): if to_save["cover_url"].endswith('/static/generic_cover.jpg'):
book.has_cover = 0 book.has_cover = 0
else: else:

View File

@ -435,7 +435,7 @@ def update_dir_structure_file(book_id, calibrepath, first_author, orignal_filepa
# Rename all files from old names to new names # Rename all files from old names to new names
try: try:
clean_author_database(renamed_author, calibrepath) clean_author_database(renamed_author, calibrepath)
if first_author not in renamed_author: if first_author and first_author not in renamed_author:
clean_author_database([first_author], calibrepath, localbook) clean_author_database([first_author], calibrepath, localbook)
if not renamed_author and not orignal_filepath and len(os.listdir(os.path.dirname(path))) == 0: if not renamed_author and not orignal_filepath and len(os.listdir(os.path.dirname(path))) == 0:
shutil.rmtree(os.path.dirname(path)) shutil.rmtree(os.path.dirname(path))
@ -581,7 +581,8 @@ def update_dir_structure(book_id,
first_author=None, first_author=None,
orignal_filepath=None, orignal_filepath=None,
db_filename=None, db_filename=None,
renamed_author=False): renamed_author=None):
renamed_author = renamed_author or []
if config.config_use_google_drive: if config.config_use_google_drive:
return update_dir_structure_gdrive(book_id, first_author, renamed_author) return update_dir_structure_gdrive(book_id, first_author, renamed_author)
else: else:

View File

@ -38,7 +38,7 @@
{% endif %} {% endif %}
{% if g.user.kindle_mail and entry.kindle_list %} {% if g.user.kindle_mail and entry.kindle_list %}
{% if entry.kindle_list.__len__() == 1 %} {% if entry.kindle_list.__len__() == 1 %}
<div id="sendbtn" data-action="{{url_for('web.send_to_kindle', book_id=entry.id, book_format=entry.kindle_list[0]['format'], convert=entry.kindle_list[0]['convert'])}}" data-text="{{_('Send to Kindle')}}" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-send"></span> {{entry.kindle_list[0]['text']}}</div> <div id="sendbtn" data-action="{{url_for('web.send_to_kindle', book_id=entry.id, book_format=entry.kindle_list[0]['format'], convert=entry.kindle_list[0]['convert'])}}" data-text="{{_('Send to Kindle')}}" class="btn btn-primary postAction" role="button"><span class="glyphicon glyphicon-send"></span> {{entry.kindle_list[0]['text']}}</div>
{% else %} {% else %}
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button id="sendbtn2" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button id="sendbtn2" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

View File

@ -40,35 +40,35 @@
{% if entries and entries[0] %} {% if entries and entries[0] %}
{% for entry in entries %} {% for entry in entries %}
<entry> <entry>
<title>{{entry.title}}</title> <title>{{entry[0].title}}</title>
<id>urn:uuid:{{entry.uuid}}</id> <id>urn:uuid:{{entry[0].uuid}}</id>
<updated>{{entry.atom_timestamp}}</updated> <updated>{{entry[0].atom_timestamp}}</updated>
{% if entry.authors.__len__() > 0 %} {% if entry[0].authors.__len__() > 0 %}
<author> <author>
<name>{{entry.authors[0].name}}</name> <name>{{entry[0].authors[0].name}}</name>
</author> </author>
{% endif %} {% endif %}
{% if entry.publishers.__len__() > 0 %} {% if entry[0].publishers.__len__() > 0 %}
<publisher> <publisher>
<name>{{entry.publishers[0].name}}</name> <name>{{entry[0].publishers[0].name}}</name>
</publisher> </publisher>
{% endif %} {% endif %}
{% for lang in entry.languages %} {% for lang in entry[0].languages %}
<dcterms:language>{{lang.lang_code}}</dcterms:language> <dcterms:language>{{lang.lang_code}}</dcterms:language>
{% endfor %} {% endfor %}
{% for tag in entry.tags %} {% for tag in entry[0].tags %}
<category scheme="http://www.bisg.org/standards/bisac_subject/index.html" <category scheme="http://www.bisg.org/standards/bisac_subject/index.html"
term="{{tag.name}}" term="{{tag.name}}"
label="{{tag.name}}"/> label="{{tag.name}}"/>
{% endfor %} {% endfor %}
{% if entry.comments[0] %}<summary>{{entry.comments[0].text|striptags}}</summary>{% endif %} {% if entry[0].comments[0] %}<summary>{{entry[0].comments[0].text|striptags}}</summary>{% endif %}
{% if entry.has_cover %} {% if entry[0].has_cover %}
<link type="image/jpeg" href="{{url_for('opds.feed_get_cover', book_id=entry.id)}}" rel="http://opds-spec.org/image"/> <link type="image/jpeg" href="{{url_for('opds.feed_get_cover', book_id=entry[0].id)}}" rel="http://opds-spec.org/image"/>
<link type="image/jpeg" href="{{url_for('opds.feed_get_cover', book_id=entry.id)}}" rel="http://opds-spec.org/image/thumbnail"/> <link type="image/jpeg" href="{{url_for('opds.feed_get_cover', book_id=entry[0].id)}}" rel="http://opds-spec.org/image/thumbnail"/>
{% endif %} {% endif %}
{% for format in entry.data %} {% for format in entry[0].data %}
<link rel="http://opds-spec.org/acquisition" href="{{ url_for('opds.opds_download_link', book_id=entry.id, book_format=format.format|lower)}}" <link rel="http://opds-spec.org/acquisition" href="{{ url_for('opds.opds_download_link', book_id=entry[0].id, book_format=format.format|lower)}}"
length="{{format.uncompressed_size}}" mtime="{{entry.atom_timestamp}}" type="{{format.format|lower|mimetype}}"/> length="{{format.uncompressed_size}}" mtime="{{entry[0].atom_timestamp}}" type="{{format.format|lower|mimetype}}"/>
{% endfor %} {% endfor %}
</entry> </entry>
{% endfor %} {% endfor %}

View File

@ -90,7 +90,7 @@ def delete_user_session(user_id, session_key):
session.query(User_Sessions).filter(User_Sessions.user_id==user_id, session.query(User_Sessions).filter(User_Sessions.user_id==user_id,
User_Sessions.session_key==session_key).delete() User_Sessions.session_key==session_key).delete()
session.commit() session.commit()
except (exc.OperationalError, exc.InvalidRequestError): except (exc.OperationalError, exc.InvalidRequestError) as e:
session.rollback() session.rollback()
log.exception(e) log.exception(e)

View File

@ -37,20 +37,20 @@
<div class="row"> <div class="row">
<div class="col-xs-6 col-md-6 col-sm-offset-3" style="margin-top:50px;"> <div class="col-xs-6 col-md-6 col-sm-offset-3" style="margin-top:50px;">
<p class='text-justify attribute'><strong>Start Time: </strong>2022-01-25 21:16:05</p> <p class='text-justify attribute'><strong>Start Time: </strong>2022-01-26 07:52:00</p>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-6 col-md-6 col-sm-offset-3"> <div class="col-xs-6 col-md-6 col-sm-offset-3">
<p class='text-justify attribute'><strong>Stop Time: </strong>2022-01-26 01:13:49</p> <p class='text-justify attribute'><strong>Stop Time: </strong>2022-01-26 11:49:33</p>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-6 col-md-6 col-sm-offset-3"> <div class="col-xs-6 col-md-6 col-sm-offset-3">
<p class='text-justify attribute'><strong>Duration: </strong>3h 17 min</p> <p class='text-justify attribute'><strong>Duration: </strong>3h 16 min</p>
</div> </div>
</div> </div>
</div> </div>
@ -1982,13 +1982,13 @@ AssertionError: 9 != 10</pre>
<tr id="su" class="failClass"> <tr id="su" class="passClass">
<td>TestLoadMetadata</td> <td>TestLoadMetadata</td>
<td class="text-center">1</td> <td class="text-center">1</td>
<td class="text-center">0</td>
<td class="text-center">1</td> <td class="text-center">1</td>
<td class="text-center">0</td> <td class="text-center">0</td>
<td class="text-center">0</td> <td class="text-center">0</td>
<td class="text-center">0</td>
<td class="text-center"> <td class="text-center">
<a onclick="showClassDetail('c14', 1)">Detail</a> <a onclick="showClassDetail('c14', 1)">Detail</a>
</td> </td>
@ -1996,42 +1996,22 @@ AssertionError: 9 != 10</pre>
<tr id="ft14.1" class="none bg-danger"> <tr id='pt14.1' class='hiddenRow bg-success'>
<td> <td>
<div class='testcase'>TestLoadMetadata - test_load_metadata</div> <div class='testcase'>TestLoadMetadata - test_load_metadata</div>
</td> </td>
<td colspan='6'> <td colspan='6' align='center'>PASS</td>
<div class="text-center">
<a class="popup_link text-center" onfocus='blur()' onclick="showTestDetail('div_ft14.1')">FAIL</a>
</div>
<!--css div popup start-->
<div id="div_ft14.1" class="popup_window test_output" style="display:block;">
<div class='close_button pull-right'>
<button type="button" class="close" aria-label="Close" onfocus="this.blur();"
onclick="document.getElementById('div_ft14.1').style.display='none'"><span
aria-hidden="true">&times;</span></button>
</div>
<div class="text-left pull-left">
<pre class="text-left">Traceback (most recent call last):
File &#34;/home/ozzie/Development/calibre-web-test/test/test_edit_books_metadata.py&#34;, line 136, in test_load_metadata
self.assertGreaterEqual(diff(BytesIO(cover), BytesIO(original_cover), delete_diff_file=True), 0.05)
AssertionError: 0.0 not greater than or equal to 0.05</pre>
</div>
<div class="clearfix"></div>
</div>
<!--css div popup end-->
</td>
</tr> </tr>
<tr id="su" class="passClass"> <tr id="su" class="errorClass">
<td>TestEditBooksOnGdrive</td> <td>TestEditBooksOnGdrive</td>
<td class="text-center">20</td> <td class="text-center">20</td>
<td class="text-center">20</td> <td class="text-center">19</td>
<td class="text-center">0</td>
<td class="text-center">0</td> <td class="text-center">0</td>
<td class="text-center">1</td>
<td class="text-center">0</td> <td class="text-center">0</td>
<td class="text-center"> <td class="text-center">
<a onclick="showClassDetail('c15', 20)">Detail</a> <a onclick="showClassDetail('c15', 20)">Detail</a>
@ -2049,11 +2029,31 @@ AssertionError: 0.0 not greater than or equal to 0.05</pre>
<tr id='pt15.2' class='hiddenRow bg-success'> <tr id="et15.2" class="none bg-info">
<td> <td>
<div class='testcase'>TestEditBooksOnGdrive - test_edit_author</div> <div class='testcase'>TestEditBooksOnGdrive - test_edit_author</div>
</td> </td>
<td colspan='6' align='center'>PASS</td> <td colspan='6'>
<div class="text-center">
<a class="popup_link text-center" onfocus='blur()' onclick="showTestDetail('div_et15.2')">ERROR</a>
</div>
<!--css div popup start-->
<div id="div_et15.2" class="popup_window test_output" style="display:block;">
<div class='close_button pull-right'>
<button type="button" class="close" aria-label="Close" onfocus="this.blur();"
onclick="document.getElementById('div_et15.2').style.display='none'"><span
aria-hidden="true">&times;</span></button>
</div>
<div class="text-left pull-left">
<pre class="text-left">Traceback (most recent call last):
File &#34;/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py&#34;, line 300, in test_edit_author
self.assertEqual(u&#39;O0ü 执&#39;, values[&#39;author&#39;][0])
IndexError: list index out of range</pre>
</div>
<div class="clearfix"></div>
</div>
<!--css div popup end-->
</td>
</tr> </tr>
@ -4925,8 +4925,8 @@ AssertionError: 200 != 500</pre>
<td>Total</td> <td>Total</td>
<td>390</td> <td>390</td>
<td>359</td> <td>359</td>
<td>17</td> <td>16</td>
<td>7</td> <td>8</td>
<td>7</td> <td>7</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
@ -5315,7 +5315,7 @@ AssertionError: 200 != 500</pre>
</div> </div>
<script> <script>
drawCircle(359, 17, 7, 7); drawCircle(359, 16, 8, 7);
showCase(5); showCase(5);
</script> </script>