summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-09-26 01:53:17 -0300
committerVictor Shyba <victor1984@riseup.net>2017-10-05 05:41:40 -0300
commit703036c34dbea644e7fb104ccaf812b00333bf4d (patch)
treea953171b7ff554da8385f6c6557fa0e2c1305c15 /tests
parent0c9bbaf5519e76841d141865f6ca76cba8d01d67 (diff)
[feature] retry during download
-- Related: #8822
Diffstat (limited to 'tests')
-rw-r--r--tests/server/test_blobs_server.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/server/test_blobs_server.py b/tests/server/test_blobs_server.py
index 7e8533fe..f27fa985 100644
--- a/tests/server/test_blobs_server.py
+++ b/tests/server/test_blobs_server.py
@@ -39,8 +39,8 @@ class BlobServerTestCase(unittest.TestCase):
def setUp(self):
root = server_blobs.BlobsResource("filesystem", self.tempdir)
- site = Site(root)
- self.port = reactor.listenTCP(0, site, interface='127.0.0.1')
+ self.site = Site(root)
+ self.port = reactor.listenTCP(0, self.site, interface='127.0.0.1')
self.host = self.port.getHost()
self.uri = 'http://%s:%s/' % (self.host.host, self.host.port)
self.secret = 'A' * 96
@@ -270,6 +270,30 @@ class BlobServerTestCase(unittest.TestCase):
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
+ def test_sync_fetch_missing_retry(self):
+ manager = BlobManager(self.tempdir, self.uri, self.secret,
+ self.secret, uuid4().hex)
+ self.addCleanup(manager.close)
+ blob_id = 'remote_only_blob_id'
+ yield manager._encrypt_and_upload(blob_id, BytesIO("X"))
+ yield manager.refresh_sync_status_from_server()
+ yield self.port.stopListening()
+
+ def sleep(x):
+ d = defer.Deferred()
+ reactor.callLater(x, d.callback, None)
+ return d
+ d = manager.fetch_missing()
+ yield sleep(1)
+ self.port = reactor.listenTCP(
+ self.host.port, self.site, interface='127.0.0.1')
+ yield d
+ result = yield manager.local.get(blob_id)
+ self.assertIsNotNone(result)
+ self.assertEquals(result.getvalue(), "X")
+
+ @defer.inlineCallbacks
+ @pytest.mark.usefixtures("method_tmpdir")
def test_upload_then_delete_updates_list(self):
manager = BlobManager('', self.uri, self.secret,
self.secret, uuid4().hex)