Commit 357cf1b3 authored by Julien Muchembled's avatar Julien Muchembled

CMFActivity: improve getMessageList() to test columns with multiple values

Because flush() relies on this method, it becomes also possible to do
  ob.flushActivity(method_id=('immediateReindexObject',
                              'recursiveImmediateReindexObject'))
parent a71be34e
......@@ -57,15 +57,22 @@ def sqltest_dict():
column = name
column_op = "%s %s " % (column, op)
def render(value, render_string):
if value is None: # XXX: see comment in SQLBase._getMessageList
assert op == '='
return column + " IS NULL"
if isinstance(value, no_quote_type):
return column_op + str(value)
if isinstance(value, DateTime):
value = value.toZone('UTC').ISO()
assert isinstance(value, basestring), value
if isinstance(value, basestring):
return column_op + render_string(value)
assert op == "=", value
if value is None: # XXX: see comment in SQLBase._getMessageList
return column + " IS NULL"
for x in value:
if isinstance(x, no_quote_type):
render_string = str
elif isinstance(x, DateTime):
value = (x.toZone('UTC').ISO() for x in value)
return "%s IN (%s)" % (column, ', '.join(map(render_string, value)))
return "0"
sqltest_dict[name] = render
_('active_process_uid')
_('group_method_id')
......
......@@ -3645,6 +3645,27 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
category_tool._delObject(c[0].getId())
self.tic()
def test_getMessageList(self):
activity_tool = self.portal.portal_activities
module = self.portal.person_module
module.activate(after_tag="foo").getUid()
module.activate(activity='SQLQueue', tag="foo").getId()
activity_tool.activate(priority=-1).getId()
def check(expected, **kw):
self.assertEqual(expected, len(activity_tool.getMessageList(**kw)))
def test(check=lambda _, **kw: check(0, **kw)):
check(2, path=module.getPath())
check(3, method_id=("getId", "getUid"))
check(1, tag="foo")
check(0, tag="foo", method_id="getUid")
check(1, processing_node=-1)
check(3, processing_node=range(-5,5))
test()
self.commit()
test(check)
self.tic()
test()
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestCMFActivity))
......
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