mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
backups: Fix failing test case
When run on empty directory FileNotFoundError is raised. Include it in the list of expected errors. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
c7f46c358d
commit
c2f7bd6354
@ -51,9 +51,13 @@ KNOWN_ERRORS = [{
|
|||||||
'message': _('Connection refused'),
|
'message': _('Connection refused'),
|
||||||
'raise_as': BorgError,
|
'raise_as': BorgError,
|
||||||
}, {
|
}, {
|
||||||
'errors': ['not a valid repository', 'does not exist'],
|
'errors': [
|
||||||
'message': _('Repository not found'),
|
'not a valid repository', 'does not exist', 'FileNotFoundError'
|
||||||
'raise_as': BorgRepositoryDoesNotExistError,
|
],
|
||||||
|
'message':
|
||||||
|
_('Repository not found'),
|
||||||
|
'raise_as':
|
||||||
|
BorgRepositoryDoesNotExistError,
|
||||||
}, {
|
}, {
|
||||||
'errors': [('passphrase supplied in BORG_PASSPHRASE or by '
|
'errors': [('passphrase supplied in BORG_PASSPHRASE or by '
|
||||||
'BORG_PASSCOMMAND is incorrect')],
|
'BORG_PASSCOMMAND is incorrect')],
|
||||||
@ -143,6 +147,7 @@ class BorgRepository():
|
|||||||
|
|
||||||
def get_download_stream(self, archive_name):
|
def get_download_stream(self, archive_name):
|
||||||
"""Return an stream of .tar.gz binary data for a backup archive."""
|
"""Return an stream of .tar.gz binary data for a backup archive."""
|
||||||
|
|
||||||
class BufferedReader(io.BufferedReader):
|
class BufferedReader(io.BufferedReader):
|
||||||
"""Improve performance of buffered binary streaming.
|
"""Improve performance of buffered binary streaming.
|
||||||
|
|
||||||
@ -156,6 +161,7 @@ class BorgRepository():
|
|||||||
binary data.
|
binary data.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
"""Override to call read() instead of readline()."""
|
"""Override to call read() instead of readline()."""
|
||||||
chunk = self.read(io.DEFAULT_BUFFER_SIZE)
|
chunk = self.read(io.DEFAULT_BUFFER_SIZE)
|
||||||
@ -210,9 +216,9 @@ class BorgRepository():
|
|||||||
"""Look whether the caught error is known and reraise it accordingly"""
|
"""Look whether the caught error is known and reraise it accordingly"""
|
||||||
caught_error = str(err)
|
caught_error = str(err)
|
||||||
for known_error in KNOWN_ERRORS:
|
for known_error in KNOWN_ERRORS:
|
||||||
for error in known_error["errors"]:
|
for error in known_error['errors']:
|
||||||
if error in caught_error:
|
if error in caught_error:
|
||||||
raise known_error["raise_as"](known_error["message"])
|
raise known_error['raise_as'](known_error['message'])
|
||||||
|
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user