From b6974fa61e18cdb3efc62482920bc3d678cefeaa Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Thu, 11 Jan 2007 22:02:05 +0000 Subject: [PATCH] add test for new ComplexQuery functionnality git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12036 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Catalog/tests/testERP5Catalog.py | 49 +++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/product/ERP5Catalog/tests/testERP5Catalog.py b/product/ERP5Catalog/tests/testERP5Catalog.py index af702d94e8..62046a34d4 100644 --- a/product/ERP5Catalog/tests/testERP5Catalog.py +++ b/product/ERP5Catalog/tests/testERP5Catalog.py @@ -852,7 +852,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.getCatalogTool().buildSQLQuery( sort_on=(('catalog.title', 'descending'),))['order_by_expression']) - def test__26_SortOnUnknownKeys(self, quiet=quiet, run=run_all_test): + def test_26_SortOnUnknownKeys(self, quiet=quiet, run=run_all_test): if not run: return if not run: return if not quiet: @@ -1264,4 +1264,49 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): [x.getObject() for x in self.getCatalogTool()( parent_title=person_module.getTitle())]) - + def test_46_QueryAndComplexQuery(self,quiet=quiet, run=1): + """ + """ + if not run: return + if not quiet: + message = 'Query And Complex Query' + ZopeTestCase._print('\n%s ' % message) + LOG('Testing... ',0,message) + org_a = self._makeOrganisation(title='abc',description='abc') + org_b = self._makeOrganisation(title='bcd',description='bcd') + org_c = self._makeOrganisation(title='efg',description='efg') + org_e = self._makeOrganisation(title='foo',description='bir') + org_f = self._makeOrganisation(title='foo',description='bar') + + from Products.ZSQLCatalog.SQLCatalog import Query,ComplexQuery + # title='abc' + catalog_kw= {'title':Query(title='abc')} + self.failIfDifferentSet([org_a.getPath()], + [x.path for x in self.getCatalogTool()( + portal_type='Organisation',**catalog_kw)]) + # title with b and c + catalog_kw= {'title':Query(title=['%b%','%c%'],operator='AND')} + self.failIfDifferentSet([org_a.getPath(), org_b.getPath()], + [x.path for x in self.getCatalogTool()( + portal_type='Organisation',**catalog_kw)]) + # title='bcd' OR description='efg' + catalog_kw = {'query':ComplexQuery(Query(title='bcd'), + Query(description='efg'), + operator='OR')} + self.failIfDifferentSet([org_b.getPath(), org_c.getPath()], + [x.path for x in self.getCatalogTool()( + portal_type='Organisation',**catalog_kw)]) + # Recursive Complex Query + # (title='abc' and description='abc') OR + # title='foo' and description='bar' + catalog_kw = {'query':ComplexQuery(ComplexQuery(Query(title='abc'), + Query(description='abc'), + operator='AND'), + ComplexQuery(Query(title='foo'), + Query(description='bar'), + operator='AND'), + operator='OR')} + self.failIfDifferentSet([org_a.getPath(), org_f.getPath()], + [x.path for x in self.getCatalogTool()( + portal_type='Organisation',**catalog_kw)]) + -- 2.30.9