From 76cbf4cbf0876e06d1d8e2839b63dffc13c271dd Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 20 Jul 2017 02:19:05 -0300 Subject: [refactor] fixes from review Improve test naming, creates a "count" method and filter flags files properly. --- src/leap/soledad/server/_blobs.py | 2 +- testing/tests/server/test_blobs_server.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index 6f298ba7..85983bd1 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -145,7 +145,7 @@ class FilesystemBlobsBackend(object): base_path = self._get_path(user, custom_preffix=namespace) count = 0 for _, _, filenames in os.walk(base_path): - count += len(filenames) + count += len(filter(lambda i: not i.endswith('.flags'), filenames)) return json.dumps({"count": count}) def list_blobs(self, user, request, namespace='', order_by=None, diff --git a/testing/tests/server/test_blobs_server.py b/testing/tests/server/test_blobs_server.py index 869ef9a0..dde25668 100644 --- a/testing/tests/server/test_blobs_server.py +++ b/testing/tests/server/test_blobs_server.py @@ -160,7 +160,7 @@ class BlobServerTestCase(unittest.TestCase): @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") - def test_list_with_count_parameter(self): + def test_count(self): manager = BlobManager('', self.uri, self.secret, self.secret, 'user') deferreds = [] @@ -168,7 +168,7 @@ class BlobServerTestCase(unittest.TestCase): deferreds.append(manager._encrypt_and_upload(str(i), BytesIO("1"))) yield defer.gatherResults(deferreds) - result = yield manager.remote_list(only_count=True) + result = yield manager.count() self.assertEquals({"count": len(deferreds)}, result) @defer.inlineCallbacks -- cgit v1.2.3