summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-09-30 01:59:44 -0300
committerVictor Shyba <victor1984@riseup.net>2017-10-05 05:43:20 -0300
commit25a35f470f597eba8479cc0178193ac963ee6350 (patch)
tree8a7732edcbb5d1cecc82ac7a0ed3b13387035f95
parentb8bdbcda11bccaf2110c441b9d4000d0fe73048a (diff)
[bug] set as PROCESSING during processing flow
It was previously setting to PROCESSED. Also added some tests to check if the underlying wrapped calls matches the intent. -- Resolves: #8955
-rw-r--r--src/leap/soledad/client/incoming.py2
-rw-r--r--tests/client/test_incoming_processing_flow.py52
2 files changed, 53 insertions, 1 deletions
diff --git a/src/leap/soledad/client/incoming.py b/src/leap/soledad/client/incoming.py
index 42522303..aa7065e8 100644
--- a/src/leap/soledad/client/incoming.py
+++ b/src/leap/soledad/client/incoming.py
@@ -131,7 +131,7 @@ class IncomingBox:
:rtype: Deferred
"""
try:
- yield self.blob_manager.set_flags(blob_id, [Flags.PROCESSED],
+ yield self.blob_manager.set_flags(blob_id, [Flags.PROCESSING],
namespace=self.namespace)
except:
defer.returnValue(None)
diff --git a/tests/client/test_incoming_processing_flow.py b/tests/client/test_incoming_processing_flow.py
index 7bc1e3c6..ec5bd717 100644
--- a/tests/client/test_incoming_processing_flow.py
+++ b/tests/client/test_incoming_processing_flow.py
@@ -20,6 +20,8 @@ Unit tests for incoming box processing flow.
from mock import Mock, call
from leap.soledad.client import interfaces
from leap.soledad.client.incoming import IncomingBoxProcessingLoop
+from leap.soledad.client.incoming import IncomingBox
+from leap.soledad.common.blobs import Flags
from twisted.internet import defer
from twisted.trial import unittest
from zope.interface import implementer
@@ -195,3 +197,53 @@ class IncomingBoxProcessingTestCase(unittest.TestCase):
self.loop.add_consumer(consumer)
yield self.loop()
self.box.set_failed.assert_has_calls([call(x) for x in items])
+
+
+class IncomingBoxCase(unittest.TestCase):
+ """
+ IncomingBox is just a wrapper for some operations on blob manager. This
+ test case checks if the underlying operations are implemented as intended.
+ """
+
+ def setUp(self):
+ self.manager = Mock()
+ self.namespace = 'mynamespace'
+ self.box = IncomingBox(self.manager, 'mynamespace')
+
+ @defer.inlineCallbacks
+ def test_fetch_for_processing_marks_as_processing(self):
+ self.manager.set_flags.return_value = defer.succeed(None)
+ some_blob = Mock()
+ self.manager.get.return_value = defer.succeed(some_blob)
+ yield self.box.fetch_for_processing('some_blob')
+
+ self.manager.set_flags.assert_called_with(
+ 'some_blob', [Flags.PROCESSING], namespace=self.namespace)
+
+ @defer.inlineCallbacks
+ def test_fetch_for_processing_returns_blob_when_set_flag_succeeds(self):
+ self.manager.set_flags.return_value = defer.succeed(None)
+ some_blob = Mock()
+ self.manager.get.return_value = defer.succeed(some_blob)
+
+ result = yield self.box.fetch_for_processing('some_blob')
+ self.assertEquals(result, some_blob)
+ self.manager.get.assert_called_with(
+ 'some_blob', namespace=self.namespace)
+
+ @defer.inlineCallbacks
+ def test_fetch_for_processing_returns_None_when_flag_fails(self):
+ self.manager.set_flags.return_value = defer.fail(Exception())
+ some_blob = Mock()
+ self.manager.get.return_value = defer.succeed(some_blob)
+
+ result = yield self.box.fetch_for_processing('some_blob')
+ self.assertEquals(result, None)
+
+ @defer.inlineCallbacks
+ def test_list_pending_asks_for_oldest_pending_flagged_blobs_by_date(self):
+ yield self.box.list_pending()
+ self.manager.remote_list.assert_called_with(
+ namespace=self.namespace,
+ order_by='+date',
+ filter_flag=Flags.PENDING)