Parcourir la source

Tests passing

Ask Solem il y a 11 ans
Parent
commit
4b21063f4b
2 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. 1 0
      celery/concurrency/base.py
  2. 19 0
      celery/tests/backends/test_redis.py

+ 1 - 0
celery/concurrency/base.py

@@ -18,6 +18,7 @@ from kombu.utils.encoding import safe_repr
 
 from celery.five import monotonic, reraise
 from celery.utils import timer2
+from celery.utils.text import truncate
 from celery.utils.log import get_logger
 
 __all__ = ['BasePool', 'apply_target']

+ 19 - 0
celery/tests/backends/test_redis.py

@@ -26,6 +26,22 @@ class Redis(object):
         def disconnect(self):
             self.connected = False
 
+    class Pipeline(object):
+
+        def __init__(self, client):
+            self.client = client
+            self.steps = []
+
+        def __getattr__(self, attr):
+
+            def add_step(*args, **kwargs):
+                self.steps.append((getattr(self.client, attr), args, kwargs))
+                return self
+            return add_step
+
+        def execute(self):
+            return [step(*a, **kw) for step, a, kw in self.steps]
+
     def __init__(self, host=None, port=None, db=None, password=None, **kw):
         self.host = host
         self.port = port
@@ -54,6 +70,9 @@ class Redis(object):
     def publish(self, key, value):
         pass
 
+    def pipeline(self):
+        return self.Pipeline(self)
+
 
 class redis(object):
     Redis = Redis