From 5d521e5a1c5fdd4cf926062dc26147dbcd110b05 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 13 Jul 2017 02:02:39 -0300 Subject: [feature] add possibility to count on blob manager By using `only_count=True` parameter, instead of returning a full list, server just count the amount of blobs. -- Resolves: #8871 --- testing/tests/server/test_blobs_server.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'testing') diff --git a/testing/tests/server/test_blobs_server.py b/testing/tests/server/test_blobs_server.py index 0db64256..0696e14b 100644 --- a/testing/tests/server/test_blobs_server.py +++ b/testing/tests/server/test_blobs_server.py @@ -126,6 +126,19 @@ class BlobServerTestCase(unittest.TestCase): blobs_list = yield manager.remote_list(order_by='-date') self.assertEquals(['blob_id1', 'blob_id2'], blobs_list) + @defer.inlineCallbacks + @pytest.mark.usefixtures("method_tmpdir") + def test_list_with_count_parameter(self): + manager = BlobManager('', self.uri, self.secret, + self.secret, 'user') + deferreds = [] + for i in range(10): + deferreds.append(manager._encrypt_and_upload(str(i), BytesIO("1"))) + yield defer.gatherResults(deferreds) + + result = yield manager.remote_list(only_count=True) + self.assertEquals({"count": len(deferreds)}, result) + @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") def test_list_restricted_by_namespace(self): -- cgit v1.2.3