diff options
author | drebs <drebs@leap.se> | 2017-12-08 22:41:59 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-12-13 13:49:27 -0200 |
commit | 601ed3ed0ffb81d743201c3819d18f79cee850f5 (patch) | |
tree | 7371fbae03760fd314d7de705a486540bccd56bf | |
parent | 7712e6b19def97cf0266146863d11d5a29767a6a (diff) |
[refactor] make get_tag() return a deferred
-rw-r--r-- | src/leap/soledad/server/_blobs.py | 2 | ||||
-rw-r--r-- | src/leap/soledad/server/interfaces.py | 4 | ||||
-rw-r--r-- | tests/blobs/test_fs_backend.py | 3 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index 7210cb6a..9d1c9b1e 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -206,7 +206,7 @@ class FilesystemBlobsBackend(object): with open(blob_path) as doc_file: doc_file.seek(-16, 2) tag = base64.urlsafe_b64encode(doc_file.read()) - return tag + return defer.succeed(tag) @defer.inlineCallbacks def _get_disk_usage(self, start_path): diff --git a/src/leap/soledad/server/interfaces.py b/src/leap/soledad/server/interfaces.py index c00b1d91..ecea0bf8 100644 --- a/src/leap/soledad/server/interfaces.py +++ b/src/leap/soledad/server/interfaces.py @@ -158,8 +158,8 @@ class IBlobsBackend(Interface): :param namespace: An optional namespace for the blob. :type namespace: str - :return: The tag of the blob. - :rtype: str + :return: A deferred that fires with the tag of the blob. + :rtype: twisted.internet.defer.Deferred """ def get_flags(user, blob_id, namespace=''): diff --git a/tests/blobs/test_fs_backend.py b/tests/blobs/test_fs_backend.py index 6c5665e8..816cba39 100644 --- a/tests/blobs/test_fs_backend.py +++ b/tests/blobs/test_fs_backend.py @@ -35,6 +35,7 @@ import pytest class FilesystemBackendTestCase(unittest.TestCase): @pytest.mark.usefixtures("method_tmpdir") + @defer.inlineCallbacks def test_get_tag(self): expected_tag = base64.urlsafe_b64encode('B' * 16) backend = _blobs.FilesystemBlobsBackend(blobs_path=self.tempdir) @@ -44,7 +45,7 @@ class FilesystemBackendTestCase(unittest.TestCase): with open(path, "w") as f: f.write('A' * 40 + 'B' * 16) # ...and get its tag - tag = backend.get_tag('user', 'blob_id') + tag = yield backend.get_tag('user', 'blob_id') self.assertEquals(expected_tag, tag) @pytest.mark.usefixtures("method_tmpdir") |