test cleanups that can be committed to trunk

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/catalog_join@41960 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fc5d23e6
...@@ -964,14 +964,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -964,14 +964,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
('catalog.title DESC', '`catalog`.`title` DESC')) ('catalog.title DESC', '`catalog`.`title` DESC'))
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 run: return
if not quiet: if not quiet:
message = 'Test Sort On Unknow Keys' message = 'Test Sort On Unknow Keys'
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
self.assertEquals('', self.assertEquals('',
self.getCatalogTool().buildSQLQuery( self.getCatalogTool().buildSQLQuery(select_list=('uid', 'path'),
sort_on=(('ignored', 'ascending'),))['order_by_expression']) sort_on=(('ignored', 'ascending'),))['order_by_expression'])
def test_27_SortOnAmbigousKeys(self, quiet=quiet, run=run_all_test): def test_27_SortOnAmbigousKeys(self, quiet=quiet, run=run_all_test):
...@@ -1037,6 +1036,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1037,6 +1036,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
'sort_on parameter must be taken into account even if related key ' 'sort_on parameter must be taken into account even if related key '
'is not a parameter of the current query') 'is not a parameter of the current query')
def _makeOrganisation(self, **kw): def _makeOrganisation(self, **kw):
"""Creates an Organisation in it's default module and reindex it. """Creates an Organisation in it's default module and reindex it.
By default, it creates a group/nexedi category, and make the organisation a By default, it creates a group/nexedi category, and make the organisation a
...@@ -1343,11 +1343,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1343,11 +1343,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# catalog those objects # catalog those objects
transaction.commit() transaction.commit()
self.tic() self.tic()
catalog_tool = self.getCatalogTool()
self.assertEquals([ob], self.assertEquals([ob],
[x.getObject() for x in self.getCatalogTool()( [x.getObject() for x in catalog_tool(portal_type='Organisation',
portal_type='Organisation', SearchableText='title')]) SearchableText='title')])
self.assertEquals(1, self.getCatalogTool().countResults( self.assertEquals(1,
portal_type='Organisation', SearchableText='title')[0][0]) catalog_tool.countResults(portal_type='Organisation',
SearchableText='title')[0][0])
# 'different' is found in more than 50% of records # 'different' is found in more than 50% of records
# MySQL ignores such a word, but Tritonn does not ignore. # MySQL ignores such a word, but Tritonn does not ignore.
...@@ -1981,7 +1983,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1981,7 +1983,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
complex_query = ComplexQuery(query1, query2, operator="AND") complex_query = ComplexQuery(query1, query2, operator="AND")
self.failIfDifferentSet([org_a.getPath() + '/default_address'], self.failIfDifferentSet([org_a.getPath() + '/default_address'],
[x.path for x in self.getCatalogTool()(query=complex_query)]) [x.path for x in self.getCatalogTool()(query=complex_query)])
# Then try without aliases # Then try with aliases
query1 = Query(parent_portal_type="Organisation", query1 = Query(parent_portal_type="Organisation",
table_alias_list=(("catalog" , "parent"),)) table_alias_list=(("catalog" , "parent"),))
query2 = Query(grand_parent_portal_type="Organisation Module", query2 = Query(grand_parent_portal_type="Organisation Module",
...@@ -4290,11 +4292,13 @@ VALUES ...@@ -4290,11 +4292,13 @@ VALUES
self.assertEqual(catalog.countResults(parent_uid=module_uid)[0][0], self.assertEqual(catalog.countResults(parent_uid=module_uid)[0][0],
module_len) module_len)
self.assertEquals(catalog.countResults(from_expression={ from_expression = {
'catalog': '(SELECT sub_catalog.* FROM catalog AS sub_catalog' \ 'catalog': '(SELECT sub_catalog.* FROM catalog AS sub_catalog'
' WHERE sub_catalog.parent_uid=%i)' \ ' WHERE sub_catalog.parent_uid=%i)'
' AS catalog' % (module_uid, ), ' AS catalog' % (module_uid, ),
})[0][0], module_len) }
count = catalog.countResults(from_expression=from_expression)[0][0]
self.assertEqual(count, module_len)
def test_getParentUid(self, quiet=quiet): def test_getParentUid(self, quiet=quiet):
from Products.ERP5Type.Document.Person import Person from Products.ERP5Type.Document.Person import Person
......
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