Explorar el Código

tests/redis: call on_chord_apply with proper arguments

Also move some imports to the top of the test file and out of the mock
patch stuff to fix this error I was getting:

    TypeError: cannot create 'NoneType' instances

Signed-off-by: Dan McGee <dan@archlinux.org>
Dan McGee hace 13 años
padre
commit
585463f5d3
Se han modificado 2 ficheros con 5 adiciones y 7 borrados
  1. 1 4
      celery/backends/redis.py
  2. 4 3
      celery/tests/test_backends/test_redis_unit.py

+ 1 - 4
celery/backends/redis.py

@@ -70,10 +70,7 @@ class RedisBackend(KeyValueStoreBackend):
     def delete(self, key):
         self.client.delete(key)
 
-    def process_cleanup(self):
-        pass
-
-    def on_chord_apply(self, *args, **kwargs):
+    def on_chord_apply(self, setid, *args, **kwargs):
         pass
 
     def on_chord_part_return(self, task, propagate=False,

+ 4 - 3
celery/tests/test_backends/test_redis_unit.py

@@ -6,6 +6,8 @@ from mock import Mock, patch
 
 from celery import current_app
 from celery import states
+from celery.registry import tasks
+from celery.task import subtask
 from celery.utils import cached_property, uuid
 from celery.utils.timeutils import timedelta_seconds
 
@@ -91,7 +93,7 @@ class test_RedisBackend(unittest.TestCase):
         self.assertEqual(b.expires, 60)
 
     def test_on_chord_apply(self):
-        self.Backend().on_chord_apply()
+        self.Backend().on_chord_apply("setid")
 
     def test_mget(self):
         b = self.MockBackend()
@@ -105,8 +107,6 @@ class test_RedisBackend(unittest.TestCase):
 
     @patch("celery.result.TaskSetResult")
     def test_on_chord_part_return(self, setresult):
-        from celery.registry import tasks
-        from celery.task import subtask
         b = self.MockBackend()
         deps = Mock()
         deps.total = 10
@@ -117,6 +117,7 @@ class test_RedisBackend(unittest.TestCase):
         try:
             tasks["foobarbaz"] = task
             task.request.chord = subtask(task)
+            task.request.taskset = "setid"
 
             b.on_chord_part_return(task)
             self.assertTrue(b.client.incr.call_count)