diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-11-09 02:41:28 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-11-10 23:06:18 -0300 |
commit | 69090db9acfa7eb33cd431a45c6c28068a20ec66 (patch) | |
tree | 817106f27b5ed666dd7d8eb6b55291f6e14e0289 /tests | |
parent | e9990fb314857d818796d8493c7eb4df052431cd (diff) |
[bug] mark deletion as pending_delete if offline
This commit creates a PENDING_DELETE sync status which can be used to
keep track of whats deleted locally in order to propagate to server
later.
-- Related: #8961
Diffstat (limited to 'tests')
-rw-r--r-- | tests/blobs/test_blob_manager.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/blobs/test_blob_manager.py b/tests/blobs/test_blob_manager.py index d36b3cda..58f99790 100644 --- a/tests/blobs/test_blob_manager.py +++ b/tests/blobs/test_blob_manager.py @@ -171,6 +171,34 @@ class BlobManagerTestCase(unittest.TestCase): @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") + def test_offline_delete_marks_as_pending_download(self): + deletion_failure = defer.fail(Exception()) + self.manager._encrypt_and_upload = Mock(return_value=None) + self.manager._delete_from_remote = Mock(return_value=deletion_failure) + content, blob_id = "Blob content", uuid4().hex + doc1 = BlobDoc(BytesIO(content), blob_id) + yield self.manager.put(doc1, len(content)) + with pytest.raises(Exception): + yield self.manager.delete(blob_id) + sync_progress = yield self.manager.sync_progress + expected = {'PENDING_DELETE': 1} + self.assertEquals(expected, sync_progress) + + @defer.inlineCallbacks + @pytest.mark.usefixtures("method_tmpdir") + def test_online_delete_marks_as_synced(self): + self.manager._encrypt_and_upload = Mock(return_value=None) + self.manager._delete_from_remote = Mock(return_value=None) + content, blob_id = "Blob content", uuid4().hex + doc1 = BlobDoc(BytesIO(content), blob_id) + yield self.manager.put(doc1, len(content)) + yield self.manager.delete(blob_id) + sync_progress = yield self.manager.sync_progress + expected = {'SYNCED': 1} + self.assertEquals(expected, sync_progress) + + @defer.inlineCallbacks + @pytest.mark.usefixtures("method_tmpdir") def test_local_sync_status_pending_upload(self): upload_failure = defer.fail(Exception()) self.manager._encrypt_and_upload = Mock(return_value=upload_failure) |