diff --git a/product/CMFActivity/Activity/SQLBase.py b/product/CMFActivity/Activity/SQLBase.py index 398d2d063e3342a39be96a672958e118a974c059..765eea486519a18041550cf94c68fb734fb232e8 100644 --- a/product/CMFActivity/Activity/SQLBase.py +++ b/product/CMFActivity/Activity/SQLBase.py @@ -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 - return column_op + render_string(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') diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py index 4922bb895025f343eb6adcdbbe4eb8655b45440b..dc12875bf129854beedd9c069462aa28353de6d1 100644 --- a/product/CMFActivity/tests/testCMFActivity.py +++ b/product/CMFActivity/tests/testCMFActivity.py @@ -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))