From 2772d76d0d66d9e094a435e110fd9f945d9e105c Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 5 Oct 2017 15:24:46 -0300 Subject: [bug] fix retries for blobs download - add a MaximumRetriesError exception to encapsulate other exceptions. - record the pending status before trying to download - modify update_sync_status to insert or update - modify retry tests to check number of retries - add a test for download retry limit --- tests/server/test_blobs_server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests/server') diff --git a/tests/server/test_blobs_server.py b/tests/server/test_blobs_server.py index 892ae5ff..c4a00ab5 100644 --- a/tests/server/test_blobs_server.py +++ b/tests/server/test_blobs_server.py @@ -34,8 +34,9 @@ from leap.soledad.client._db.blobs import BlobAlreadyExistsError from leap.soledad.client._db.blobs import InvalidFlagsError from leap.soledad.client._db.blobs import SoledadError from leap.soledad.client._db.blobs import SyncStatus +from leap.soledad.client._db.blobs import RetriableTransferError +from leap.soledad.client._db.blobs import MaximumRetriesError from leap.soledad.client._db import blobs as client_blobs -from leap.soledad.client._crypto import InvalidBlob def sleep(x): @@ -333,7 +334,7 @@ class BlobServerTestCase(unittest.TestCase): # Corrupt the tag (last 16 bytes) corrupted_blob.seek(-16, 2) corrupted_blob.write('x' * 16) - with pytest.raises(InvalidBlob): + with pytest.raises(MaximumRetriesError): yield manager.sync() status, retries = yield manager.local.get_sync_status(blob_id) self.assertEquals(status, SyncStatus.FAILED_DOWNLOAD) @@ -370,7 +371,7 @@ class BlobServerTestCase(unittest.TestCase): manager = BlobManager(self.tempdir, self.uri, self.secret, self.secret, uuid4().hex) self.addCleanup(manager.close) - with pytest.raises(SoledadError): + with pytest.raises(RetriableTransferError): yield manager.get('missing_id') @defer.inlineCallbacks -- cgit v1.2.3