summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-12-18 17:06:23 -0200
committerdrebs <drebs@leap.se>2017-12-19 15:22:41 -0200
commita3e3307fdc384be45ce4c62b95585d1825d4c849 (patch)
tree9bf5d1367511bc6c963b35bb5f892e5a4afe49f0
parent5e69a05a6762544ffa025b4b5e5ba9b6af9a88a4 (diff)
[test] use producer in all fs backend tests
-rw-r--r--tests/blobs/test_fs_backend.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/blobs/test_fs_backend.py b/tests/blobs/test_fs_backend.py
index fc3d649a..99a2a760 100644
--- a/tests/blobs/test_fs_backend.py
+++ b/tests/blobs/test_fs_backend.py
@@ -20,7 +20,6 @@ Tests for blobs backend on server side.
from twisted.trial import unittest
from twisted.internet import defer
from twisted.web.client import FileBodyProducer
-from twisted.web.test.test_web import DummyRequest
from leap.common.files import mkdir_p
from leap.soledad.server import _blobs
from mock import Mock
@@ -83,8 +82,8 @@ class FilesystemBackendTestCase(unittest.TestCase):
isfile.return_value = True
backend = _blobs.FilesystemBlobsBackend(blobs_path=self.tempdir)
with pytest.raises(_blobs.BlobExists):
- fd = Mock()
- yield backend.write_blob('user', 'blob_id', fd)
+ producer = Mock()
+ yield backend.write_blob('user', 'blob_id', producer)
@pytest.mark.usefixtures("method_tmpdir")
@mock.patch.object(os.path, 'isfile')
@@ -95,8 +94,8 @@ class FilesystemBackendTestCase(unittest.TestCase):
backend.get_total_storage = lambda x: defer.succeed(100)
backend.quota = 90
with pytest.raises(_blobs.QuotaExceeded):
- fd = Mock()
- yield backend.write_blob('user', 'blob_id', fd)
+ producer = FileBodyProducer(io.BytesIO('a' * 100))
+ yield backend.write_blob('user', 'blob_id', producer)
@pytest.mark.usefixtures("method_tmpdir")
def test_get_path_partitioning_by_default(self):
@@ -146,30 +145,31 @@ class FilesystemBackendTestCase(unittest.TestCase):
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
def test_path_validation_on_read_blob(self):
- blobs_path, request = self.tempdir, DummyRequest([''])
+ blobs_path, producer = self.tempdir, Mock()
backend = _blobs.FilesystemBlobsBackend(blobs_path=blobs_path)
with pytest.raises(Exception):
- yield backend.read_blob('..', '..', request)
+ yield backend.read_blob('..', '..', producer)
with pytest.raises(Exception):
- yield backend.read_blob('user', '../../../', request)
+ yield backend.read_blob('user', '../../../', producer)
with pytest.raises(Exception):
- yield backend.read_blob('../../../', 'blob_id', request)
+ yield backend.read_blob('../../../', 'blob_id', producer)
with pytest.raises(Exception):
- yield backend.read_blob('user', 'blob_id', request, namespace='..')
+ yield backend.read_blob('user', 'blob_id', producer,
+ namespace='..')
@pytest.mark.usefixtures("method_tmpdir")
@defer.inlineCallbacks
def test_path_validation_on_write_blob(self):
- blobs_path, request = self.tempdir, DummyRequest([''])
+ blobs_path, producer = self.tempdir, Mock()
backend = _blobs.FilesystemBlobsBackend(blobs_path=blobs_path)
with pytest.raises(Exception):
- yield backend.write_blob('..', '..', request)
+ yield backend.write_blob('..', '..', producer)
with pytest.raises(Exception):
- yield backend.write_blob('user', '../../../', request)
+ yield backend.write_blob('user', '../../../', producer)
with pytest.raises(Exception):
- yield backend.write_blob('../../../', 'id1', request)
+ yield backend.write_blob('../../../', 'id1', producer)
with pytest.raises(Exception):
- yield backend.write_blob('user', 'id2', request, namespace='..')
+ yield backend.write_blob('user', 'id2', producer, namespace='..')
@pytest.mark.usefixtures("method_tmpdir")
@mock.patch('leap.soledad.server._blobs.os.unlink')