From 26a65d100f91883027c17c219d018461968eda65 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 23 Mar 2017 20:33:20 -0300 Subject: [feature] add blobs listing --- testing/tests/blobs/test_fs_backend.py | 9 +++++++++ testing/tests/server/test_blobs_server.py | 11 +++++++++++ 2 files changed, 20 insertions(+) (limited to 'testing/tests') diff --git a/testing/tests/blobs/test_fs_backend.py b/testing/tests/blobs/test_fs_backend.py index ce82fce0..5be6c17d 100644 --- a/testing/tests/blobs/test_fs_backend.py +++ b/testing/tests/blobs/test_fs_backend.py @@ -25,6 +25,7 @@ from mock import Mock import mock import os import base64 +import json import pytest @@ -86,3 +87,11 @@ class FilesystemBackendTestCase(unittest.TestCase): backend.path = '/somewhere/' path = backend._get_path('user', 'blob_id') assert path == '/somewhere/user/b/blo/blob_i/blob_id' + + @pytest.mark.usefixtures("method_tmpdir") + @mock.patch('leap.soledad.server._blobs.os.walk') + def test_list_blobs(self, walk_mock): + backend, _ = _blobs.FilesystemBlobsBackend(self.tempdir), None + walk_mock.return_value = [(_, _, ['blob_0']), (_, _, ['blob_1'])] + result = json.loads(backend.list_blobs('user', DummyRequest(['']))) + assert result == ['blob_0', 'blob_1'] diff --git a/testing/tests/server/test_blobs_server.py b/testing/tests/server/test_blobs_server.py index 1f35c285..3c534c0c 100644 --- a/testing/tests/server/test_blobs_server.py +++ b/testing/tests/server/test_blobs_server.py @@ -51,6 +51,17 @@ class BlobServerTestCase(unittest.TestCase): 'mydoc', '1') assert blob.getvalue() == "save me" + @defer.inlineCallbacks + @pytest.mark.usefixtures("method_tmpdir") + def test_upload_list(self): + manager = BlobManager('', self.uri, self.secret, + self.secret, 'user') + yield manager._encrypt_and_upload('blob_id1', '1', '1', BytesIO("1")) + yield manager._encrypt_and_upload('blob_id2', '2', '2', BytesIO("2")) + blobs_list = yield manager.list() + assert len(blobs_list) == 2 + assert 'blob_id1' in blobs_list and 'blob_id2' in blobs_list + @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") def test_upload_deny_duplicates(self): -- cgit v1.2.3