summaryrefslogtreecommitdiff
path: root/testing/tests/blobs
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-05-02 00:08:27 -0300
committerVictor Shyba <victor1984@riseup.net>2017-05-02 00:18:32 -0300
commit8a6c8274c37b045d1a6198b6ff585940811da18a (patch)
treee9f9cbaf6ed77d1cc5c643df949cc904aafaaeeb /testing/tests/blobs
parent03617fc9378b9f8cf6fec77bd53c573131ade75b (diff)
[feature] add and integrate DELETE to blobs server
Add a DELETE method for blobs server and integrate it into client's BlobManager. - Resolves: #8846
Diffstat (limited to 'testing/tests/blobs')
-rw-r--r--testing/tests/blobs/test_blob_manager.py13
-rw-r--r--testing/tests/blobs/test_fs_backend.py8
2 files changed, 21 insertions, 0 deletions
diff --git a/testing/tests/blobs/test_blob_manager.py b/testing/tests/blobs/test_blob_manager.py
index 69a272c8..4d04e09d 100644
--- a/testing/tests/blobs/test_blob_manager.py
+++ b/testing/tests/blobs/test_blob_manager.py
@@ -130,3 +130,16 @@ class BlobManagerTestCase(unittest.TestCase):
with pytest.raises(BlobAlreadyExistsError):
yield self.manager.put(doc2, len(content))
self.assertFalse(self.manager._encrypt_and_upload.called)
+
+ @defer.inlineCallbacks
+ @pytest.mark.usefixtures("method_tmpdir")
+ def test_delete_from_local_and_remote(self):
+ self.manager._encrypt_and_upload = Mock(return_value=None)
+ self.manager._delete_from_remote = Mock(return_value=None)
+ content = "Blob content"
+ doc1 = BlobDoc(BytesIO(content), 'blob_id')
+ yield self.manager.put(doc1, len(content))
+ yield self.manager.delete('blob_id')
+ local_list = yield self.manager.local_list()
+ self.assertEquals(0, len(local_list))
+ self.manager._delete_from_remote.assert_called_with('blob_id')
diff --git a/testing/tests/blobs/test_fs_backend.py b/testing/tests/blobs/test_fs_backend.py
index f6f2db2d..83a5708e 100644
--- a/testing/tests/blobs/test_fs_backend.py
+++ b/testing/tests/blobs/test_fs_backend.py
@@ -120,3 +120,11 @@ class FilesystemBackendTestCase(unittest.TestCase):
yield backend.write_blob('valid', '../../../', DummyRequest(['']))
with pytest.raises(Exception):
yield backend.write_blob('../../../', 'valid', DummyRequest(['']))
+
+ @pytest.mark.usefixtures("method_tmpdir")
+ @mock.patch('leap.soledad.server._blobs.os.unlink')
+ def test_delete_blob(self, unlink_mock):
+ backend = _blobs.FilesystemBlobsBackend(self.tempdir)
+ backend.delete_blob('user', 'blob_id')
+ unlink_mock.assert_called_once_with(backend._get_path('user',
+ 'blob_id'))