Commit 331625e2 authored by Julien Muchembled's avatar Julien Muchembled

CMFActivity: fix test_mergeParent on Python 2.7

Messages passed to a grouping method are not sorted.
parent cc1f0763
...@@ -3574,13 +3574,11 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3574,13 +3574,11 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
c = [category_tool.newContent()] c = [category_tool.newContent()]
for i in xrange(5): for i in xrange(5):
c.append(c[i//2].newContent()) c.append(c[i//2].newContent())
transaction.commit()
self.tic() self.tic()
def activate(i, priority=1, **kw): def activate(i, priority=1, **kw):
kw.setdefault('merge_parent', c[0].getPath()) kw.setdefault('merge_parent', c[0].getPath())
c[i].activate(priority=priority, **kw).doSomething() c[i].activate(priority=priority, **kw).doSomething()
def check(*expected): def check(*expected):
transaction.commit()
self.tic() self.tic()
self.assertEquals(tuple(invoked), expected) self.assertEquals(tuple(invoked), expected)
del invoked[:] del invoked[:]
...@@ -3609,10 +3607,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3609,10 +3607,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
merge_parent=c[(i-1)//2 or i].getPath(), merge_parent=c[(i-1)//2 or i].getPath(),
priority=priority, **kw).doSomething() priority=priority, **kw).doSomething()
def invokeGroup(self, message_list): def invokeGroup(self, message_list):
invoked.append([c.index(m[0]) for m in message_list]) invoked.append(sorted(c.index(m[0]) for m in message_list))
category_tool.__class__.invokeGroup = invokeGroup category_tool.__class__.invokeGroup = invokeGroup
try: try:
activate(5, 0); activate(1, 1); check([5, 1]) activate(5, 0); activate(1, 1); check([1, 5])
activate(4, 0); activate(1, 1); activate(2, 0); check([1, 2]) activate(4, 0); activate(1, 1); activate(2, 0); check([1, 2])
activate(1, 0); activate(5, 0); activate(3, 1); check([1, 5]) activate(1, 0); activate(5, 0); activate(3, 1); check([1, 5])
for p, i in enumerate((5, 3, 2, 1, 4)): for p, i in enumerate((5, 3, 2, 1, 4)):
...@@ -3621,11 +3619,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3621,11 +3619,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
for cost in 0.3, 0.1: for cost in 0.3, 0.1:
activate(2, 0, group_method_cost=cost) activate(2, 0, group_method_cost=cost)
activate(3, 1); activate(4, 2); activate(1, 3) activate(3, 1); activate(4, 2); activate(1, 3)
check([2, 1]) check([1, 2])
finally: finally:
del category_tool.__class__.invokeGroup del category_tool.__class__.invokeGroup
category_tool._delObject(c[0].getId()) category_tool._delObject(c[0].getId())
transaction.commit()
self.tic() self.tic()
def test_suite(): def test_suite():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment