From 598618e4285d4450c74c9920941eef3242db880e Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 1 Mar 2022 16:36:46 +0100 Subject: [PATCH] Fix rename_files_on_change return handling Updated test result --- cps/helper.py | 11 +- test/Calibre-Web TestSummary_Linux.html | 2491 ++++------------------- 2 files changed, 350 insertions(+), 2152 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index c162f7ee..03a2d03b 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -493,12 +493,10 @@ def upload_new_file_gdrive(book_id, first_author, renamed_author, title, title_d title_dir + " (" + str(book_id) + ")") book.path = gdrive_path.replace("\\", "/") gd.uploadFileToEbooksFolder(os.path.join(gdrive_path, file_name).replace("\\", "/"), original_filepath) - error |= rename_files_on_change(first_author, renamed_author, localbook=book, gdrive=True) - return error + return rename_files_on_change(first_author, renamed_author, localbook=book, gdrive=True) def update_dir_structure_gdrive(book_id, first_author, renamed_author): - error = False book = calibre_db.get_book(book_id) authordir = book.path.split('/')[0] @@ -513,7 +511,7 @@ def update_dir_structure_gdrive(book_id, first_author, renamed_author): book.path = book.path.split('/')[0] + u'/' + new_titledir gd.updateDatabaseOnEdit(gFile['id'], book.path) # only child folder affected else: - error = _(u'File %(file)s not found on Google Drive', file=book.path) # file not found + return _(u'File %(file)s not found on Google Drive', file=book.path) # file not found if authordir != new_authordir and authordir not in renamed_author: gFile = gd.getFileFromEbooksFolder(os.path.dirname(book.path), new_titledir) @@ -522,12 +520,11 @@ def update_dir_structure_gdrive(book_id, first_author, renamed_author): book.path = new_authordir + u'/' + book.path.split('/')[1] gd.updateDatabaseOnEdit(gFile['id'], book.path) else: - error = _(u'File %(file)s not found on Google Drive', file=authordir) # file not found + return _(u'File %(file)s not found on Google Drive', file=authordir) # file not found # change location in database to new author/title path book.path = os.path.join(new_authordir, new_titledir).replace('\\', '/') - error |= rename_files_on_change(first_author, renamed_author, book, gdrive=True) - return error + return rename_files_on_change(first_author, renamed_author, book, gdrive=True) def move_files_on_change(calibre_path, new_authordir, new_titledir, localbook, db_filename, original_filepath, path): diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index af8cfcd9..c569a45d 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2022-02-05 20:19:09

+

Start Time: 2022-02-28 21:38:15

-

Stop Time: 2022-02-06 00:20:42

+

Stop Time: 2022-03-01 01:36:56

-

Duration: 3h 15 min

+

Duration: 3h 14 min

@@ -330,13 +330,13 @@ - + TestCliGdrivedb 2 - 0 - 0 2 0 + 0 + 0 Detail @@ -344,89 +344,20 @@ - +
TestCliGdrivedb - test_cli_gdrive_location
- -
- ERROR -
- - - - + PASS - +
TestCliGdrivedb - test_gdrive_db_nonwrite
- -
- ERROR -
- - - - + PASS @@ -1496,9 +1427,9 @@ receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_author_gdrive.py", line 544, in test_rename_capital_on_upload
-    self.check_element_on_page((By.ID, 'edit_cancel')).click()
-AttributeError: 'bool' object has no attribute 'click'
+ File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_author_gdrive.py", line 579, in test_rename_capital_on_upload + self.assertEqual('Useless', details['title']) +KeyError: 'title'
@@ -1713,9 +1644,9 @@ AttributeError: 'bool' object has no attribute 'click' TestEditBooksOnGdrive 20 - 0 - 0 - 20 + 15 + 3 + 2 0 Detail @@ -1724,31 +1655,11 @@ AttributeError: 'bool' object has no attribute 'click' - +
TestEditBooksOnGdrive - test_download_book
- -
- ERROR -
- - - - + PASS @@ -1770,77 +1681,9 @@ TypeError: object of type 'bool' has no len()
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
-    conn = connection.create_connection(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
-    raise err
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
-    sock.connect(sa)
-ConnectionRefusedError: [Errno 111] Connection refused
-
-During handling of the above exception, another exception occurred:
-
-Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
-    httplib_response = self._make_request(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 398, in _make_request
-    conn.request(method, url, **httplib_request_kw)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
-    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
-  File "/usr/lib/python3.8/http/client.py", line 1256, in request
-    self._send_request(method, url, body, headers, encode_chunked)
-  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
-    self.endheaders(body, encode_chunked=encode_chunked)
-  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
-    self._send_output(message_body, encode_chunked=encode_chunked)
-  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
-    self.send(msg)
-  File "/usr/lib/python3.8/http/client.py", line 951, in send
-    self.connect()
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
-    conn = self._new_conn()
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
-    raise NewConnectionError(
-urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f7cee201a90>: Failed to establish a new connection: [Errno 111] Connection refused
-
-During handling of the above exception, another exception occurred:
-
-Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 291, in test_edit_author
-    self.fill_basic_config({"config_unicode_filename": 1})
-  File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 358, in fill_basic_config
-    cls._fill_basic_config(elements)
-  File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 268, in _fill_basic_config
-    WebDriverWait(cls.driver, 5).until(EC.presence_of_element_located((By.ID, "config_port")))
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 78, in until
-    value = method(self._driver)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/support/expected_conditions.py", line 64, in _predicate
-    return driver.find_element(*locator)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1244, in find_element
-    return self.execute(Command.FIND_ELEMENT, {
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 422, in execute
-    response = self.command_executor.execute(driver_command, params)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/remote_connection.py", line 421, in execute
-    return self._request(command_info[0], url, body=data)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/remote_connection.py", line 443, in _request
-    resp = self._conn.request(method, url, body=body, headers=headers)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/request.py", line 78, in request
-    return self.request_encode_body(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/request.py", line 170, in request_encode_body
-    return self.urlopen(method, url, **extra_kw)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/poolmanager.py", line 375, in urlopen
-    response = conn.urlopen(method, u.request_uri, **kw)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 813, in urlopen
-    return self.urlopen(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 813, in urlopen
-    return self.urlopen(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 813, in urlopen
-    return self.urlopen(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 785, in urlopen
-    retries = retries.increment(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
-    raise MaxRetryError(_pool, url, error or ResponseError(cause))
-urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=51341): Max retries exceeded with url: /session/2d4e9139-cf96-4ca3-bca3-9646475259b3/element (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7cee201a90>: Failed to establish a new connection: [Errno 111] Connection refused'))
+ File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 392, in test_edit_author + self.assertEqual(values['author'][0], 'Pipo, Pipe') +IndexError: list index out of range
@@ -1850,751 +1693,119 @@ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', p - +
TestEditBooksOnGdrive - test_edit_category
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_comments
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_bool
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_categories
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_float
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_int
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_rating
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_single_select
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_custom_text
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_language
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_publisher
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_rating
- -
- ERROR -
- - - - + PASS - +
TestEditBooksOnGdrive - test_edit_series
- -
- ERROR -
- - - - + PASS @@ -2616,77 +1827,9 @@ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', p
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
-    conn = connection.create_connection(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
-    raise err
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
-    sock.connect(sa)
-ConnectionRefusedError: [Errno 111] Connection refused
-
-During handling of the above exception, another exception occurred:
-
-Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
-    httplib_response = self._make_request(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 398, in _make_request
-    conn.request(method, url, **httplib_request_kw)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
-    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
-  File "/usr/lib/python3.8/http/client.py", line 1256, in request
-    self._send_request(method, url, body, headers, encode_chunked)
-  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
-    self.endheaders(body, encode_chunked=encode_chunked)
-  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
-    self._send_output(message_body, encode_chunked=encode_chunked)
-  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
-    self.send(msg)
-  File "/usr/lib/python3.8/http/client.py", line 951, in send
-    self.connect()
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
-    conn = self._new_conn()
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
-    raise NewConnectionError(
-urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f7cec623f40>: Failed to establish a new connection: [Errno 111] Connection refused
-
-During handling of the above exception, another exception occurred:
-
-Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 133, in test_edit_title
-    self.fill_basic_config({"config_unicode_filename": 1})
-  File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 358, in fill_basic_config
-    cls._fill_basic_config(elements)
-  File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 268, in _fill_basic_config
-    WebDriverWait(cls.driver, 5).until(EC.presence_of_element_located((By.ID, "config_port")))
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 78, in until
-    value = method(self._driver)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/support/expected_conditions.py", line 64, in _predicate
-    return driver.find_element(*locator)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1244, in find_element
-    return self.execute(Command.FIND_ELEMENT, {
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 422, in execute
-    response = self.command_executor.execute(driver_command, params)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/remote_connection.py", line 421, in execute
-    return self._request(command_info[0], url, body=data)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/remote_connection.py", line 443, in _request
-    resp = self._conn.request(method, url, body=body, headers=headers)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/request.py", line 78, in request
-    return self.request_encode_body(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/request.py", line 170, in request_encode_body
-    return self.urlopen(method, url, **extra_kw)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/poolmanager.py", line 375, in urlopen
-    response = conn.urlopen(method, u.request_uri, **kw)
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 813, in urlopen
-    return self.urlopen(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 813, in urlopen
-    return self.urlopen(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 813, in urlopen
-    return self.urlopen(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 785, in urlopen
-    retries = retries.increment(
-  File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
-    raise MaxRetryError(_pool, url, error or ResponseError(cause))
-urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=51341): Max retries exceeded with url: /session/2d4e9139-cf96-4ca3-bca3-9646475259b3/element (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7cec623f40>: Failed to establish a new connection: [Errno 111] Connection refused'))
+ File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 183, in test_edit_title + self.assertEqual('Unknown', values['title']) +KeyError: 'title'
@@ -2696,94 +1839,28 @@ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', p - +
TestEditBooksOnGdrive - test_upload_book_epub
- ERROR + FAIL
-