summaryrefslogtreecommitdiff
path: root/t/unit/utils
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2016-09-02 15:35:39 -0700
committerAsk Solem <ask@celeryproject.org>2016-09-02 15:39:45 -0700
commit84fc45b9a76026c054ab1d31ec3883dd2e56c440 (patch)
treeba4f0b2b09670ef505470b97b155a61e5b5e2867 /t/unit/utils
parentf71ea5c803a29706afd195ef570607838dc53519 (diff)
downloadkombu-84fc45b9a76026c054ab1d31ec3883dd2e56c440.tar.gz
Virtual transport deliver now calls callback, no return value. Fixes #593
Diffstat (limited to 't/unit/utils')
-rw-r--r--t/unit/utils/test_scheduling.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/t/unit/utils/test_scheduling.py b/t/unit/utils/test_scheduling.py
index 894286cd..79216b56 100644
--- a/t/unit/utils/test_scheduling.py
+++ b/t/unit/utils/test_scheduling.py
@@ -2,6 +2,8 @@ from __future__ import absolute_import, unicode_literals
import pytest
+from case import Mock
+
from kombu.utils.scheduling import FairCycle, cycle_by_name
@@ -12,7 +14,7 @@ class MyEmpty(Exception):
def consume(fun, n):
r = []
for i in range(n):
- r.append(fun())
+ r.append(fun(Mock(name='callback')))
return r
@@ -20,6 +22,7 @@ class test_FairCycle:
def test_cycle(self):
resources = ['a', 'b', 'c', 'd', 'e']
+ callback = Mock(name='callback')
def echo(r, timeout=None):
return r
@@ -27,26 +30,24 @@ class test_FairCycle:
# cycle should be ['a', 'b', 'c', 'd', 'e', ... repeat]
cycle = FairCycle(echo, resources, MyEmpty)
for i in range(len(resources)):
- assert cycle.get() == (resources[i], resources[i])
+ assert cycle.get(callback) == resources[i]
for i in range(len(resources)):
- assert cycle.get() == (resources[i], resources[i])
+ assert cycle.get(callback) == resources[i]
def test_cycle_breaks(self):
resources = ['a', 'b', 'c', 'd', 'e']
- def echo(r):
+ def echo(r, callback):
if r == 'c':
raise MyEmpty(r)
return r
cycle = FairCycle(echo, resources, MyEmpty)
assert consume(cycle.get, len(resources)) == [
- ('a', 'a'), ('b', 'b'), ('d', 'd'),
- ('e', 'e'), ('a', 'a'),
+ 'a', 'b', 'd', 'e', 'a',
]
assert consume(cycle.get, len(resources)) == [
- ('b', 'b'), ('d', 'd'), ('e', 'e'),
- ('a', 'a'), ('b', 'b'),
+ 'b', 'd', 'e', 'a', 'b',
]
cycle2 = FairCycle(echo, ['c', 'c'], MyEmpty)
with pytest.raises(MyEmpty):