Browse Source

Tests passing

Ask Solem 12 years ago
parent
commit
c029fa851a

+ 1 - 0
celery/backends/cache.py

@@ -115,6 +115,7 @@ class CacheBackend(KeyValueStoreBackend):
 
     def on_chord_apply(self, group_id, body, result=None, **kwargs):
         self.client.set(self.get_key_for_chord(group_id), '0', time=86400)
+        print('GROUP_ID: %r RESULT: %r' % (group_id, result))
         self.app.GroupResult(group_id, result).save()
 
     def incr(self, key):

+ 5 - 3
celery/tests/backends/test_cache.py

@@ -58,7 +58,8 @@ class test_CacheBackend(Case):
 
     def test_on_chord_apply(self):
         tb = CacheBackend(backend='memory://')
-        tb.on_chord_apply('group_id', [])
+        gid, res = uuid(), [AsyncResult(uuid()) for _ in xrange(3)]
+        tb.on_chord_apply(gid, {}, result=res)
 
     @patch('celery.result.GroupResult')
     def test_on_chord_part_return(self, setresult):
@@ -73,9 +74,10 @@ class test_CacheBackend(Case):
         try:
             current_app.tasks['foobarbaz'] = task
             task.request.chord = subtask(task)
-            task.request.group = 'group_id'
 
-            tb.on_chord_apply(task.request.group, [])
+            gid, res = uuid(), [AsyncResult(uuid()) for _ in xrange(3)]
+            task.request.group = gid
+            tb.on_chord_apply(gid, {}, result=res)
 
             self.assertFalse(deps.join_native.called)
             tb.on_chord_part_return(task)

+ 9 - 5
celery/tests/worker/test_hub.py

@@ -152,6 +152,8 @@ class test_Hub(Case):
         e1, e2, e3 = Mock(), Mock(), Mock()
         entries = [e1, e2, e3]
 
+        reset = lambda: [m.reset() for m in [e1, e2, e3]]
+
         def se():
             if entries:
                 return None, entries.pop()
@@ -160,16 +162,18 @@ class test_Hub(Case):
         hub.scheduler.next.side_effect = se
 
         self.assertEqual(hub.fire_timers(max_timers=10), 3.982)
-        hub.timer.apply_entry.assert_has_calls(map(call, [e3, e2, e1]))
+        for E in [e3, e2, e1]:
+            E.assert_called_with()
+        reset()
 
         entries[:] = [Mock() for _ in xrange(11)]
         keep = list(entries)
         self.assertEqual(hub.fire_timers(max_timers=10, min_delay=1.13), 1.13)
-        hub.timer.apply_entry.assert_has_calls(
-            map(call, reversed(keep[1:])),
-        )
+        for E in reversed(keep[1:]):
+            E.assert_called_with()
+        reset()
         self.assertEqual(hub.fire_timers(max_timers=10), 3.982)
-        hub.timer.apply_entry.assert_has_calls(call(keep[0]))
+        keep[0].assert_called_with()
 
     def test_update_readers(self):
         hub = Hub()

+ 1 - 0
celery/worker/hub.py

@@ -151,6 +151,7 @@ class Hub(object):
         if self.timer._queue:
             for i in range(max_timers):
                 delay, entry = self.scheduler.next()
+                print('D; %r, E; %r' % (delay, entry))
                 if entry is None:
                     break
                 try: