summaryrefslogtreecommitdiff
path: root/testing/tests/blobs
diff options
context:
space:
mode:
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'))