summaryrefslogtreecommitdiff
path: root/testing/tests/blobs/test_blobs.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests/blobs/test_blobs.py')
-rw-r--r--testing/tests/blobs/test_blobs.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/testing/tests/blobs/test_blobs.py b/testing/tests/blobs/test_blobs.py
index a36bad1e..77eff6cc 100644
--- a/testing/tests/blobs/test_blobs.py
+++ b/testing/tests/blobs/test_blobs.py
@@ -19,10 +19,11 @@ Tests for cryptographic related stuff.
"""
from twisted.trial import unittest
from twisted.internet import defer
-from leap.soledad.client import _blobs
-from leap.soledad.client._blobs import DecrypterBuffer
+from leap.soledad.client._blobs import DecrypterBuffer, BlobManager
from leap.soledad.client import _crypto
from io import BytesIO
+from mock import Mock
+import mock
class BlobTestCase(unittest.TestCase):
@@ -49,20 +50,22 @@ class BlobTestCase(unittest.TestCase):
fd, size = buf.close()
assert fd.getvalue() == 'rosa de foc'
+ @defer.inlineCallbacks
def test_blob_manager_encrypted_upload(self):
@defer.inlineCallbacks
- def _check_result(uri, data):
+ def _check_result(uri, data, *args, **kwargs):
decryptor = _crypto.BlobDecryptor(
self.doc_info, data,
armor=False,
secret=self.secret)
decrypted = yield decryptor.decrypt()
assert decrypted.getvalue() == 'up and up'
+ defer.returnValue(Mock(code=200))
- manager = _blobs.BlobManager(
- '', 'http://127.0.0.1/', self.secret, self.secret, 'user')
+ manager = BlobManager('', '', self.secret, self.secret, 'user')
doc_id, rev = self.doc_info.doc_id, self.doc_info.rev
fd = BytesIO('up and up')
- manager._client.put = _check_result
- return manager._encrypt_and_upload('blob_id', doc_id, rev, fd)
+ with mock.patch('leap.soledad.client._blobs.treq.put') as mock_treq:
+ mock_treq.side_effect = _check_result
+ yield manager._encrypt_and_upload('blob_id', doc_id, rev, fd)