Commit bed98b6f authored by Vincent Pelletier's avatar Vincent Pelletier

testERP5Catalog: Drop disabled incomplete test for non-feature.

ZSQLCatalog/ERP5Catalog is only supposed to work on catalog table, by
definition.
parent 003bb75c
......@@ -514,117 +514,6 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertTrue(organisation.getModificationDate()>now)
self.assertTrue(result[0]['creation_date']<result[0]['modification_date'])
# TODO: this test is disabled (and maybe not complete), because this feature
# is not implemented
@todo_erp5
def test_18_buildSQLQueryAnotherTable(self):
"""Tests that buildSQLQuery works with another query_table than 'catalog'"""
portal = self.getPortal()
portal_catalog = self.getCatalogTool()
# clear catalog
portal_catalog.manage_catalogClear()
self.commit()
# create some content to use destination_section_title as related key
# FIXME: create the related key here ?
module = portal.getDefaultModule('Organisation')
source_organisation = module.newContent( portal_type='Organisation',
title = 'source_organisation')
destination_organisation = module.newContent( portal_type='Organisation',
title = 'destination_organisation')
source_organisation.setDestinationSectionValue(destination_organisation)
source_organisation.recursiveReindexObject()
destination_organisation.recursiveReindexObject()
self.tic()
# buildSQLQuery can use arbitrary table name.
query_table = "node"
sql_squeleton = """
SELECT %(query_table)s.uid,
%(query_table)s.id
FROM
<dtml-in prefix="table" expr="from_table_list">
<dtml-var table_item> AS <dtml-var table_key>
<dtml-unless sequence-end>, </dtml-unless>
</dtml-in>
<dtml-if where_expression>
WHERE
<dtml-var where_expression>
</dtml-if>
<dtml-if order_by_expression>
ORDER BY <dtml-var order_by_expression>
</dtml-if>
""" % {'query_table' : query_table}
portal_skins_custom = portal.portal_skins.custom
portal_skins_custom.newContent(
portal_type='SQL Method',
id='testMethod',
title='',
connection_id='erp5_sql_connection',
arguments_src="\n".join([ 'from_table_list',
'where_expression',
'order_by_expression' ]),
src=sql_squeleton)
testMethod = portal_skins_custom['testMethod']
default_parametrs = {}
default_parametrs['portal_type'] = 'Organisation'
default_parametrs['from_table_list'] = {}
default_parametrs['where_expression'] = ""
default_parametrs['order_by_expression'] = None
# check that we retrieve our 2 organisations by default.
kw = default_parametrs.copy()
kw.update( portal_catalog.buildSQLQuery(
query_table = query_table,
**kw) )
LOG('kw', 0, kw)
LOG('SQL', 0, testMethod(src__=1, **kw))
self.assertEqual(len(testMethod(**kw)), 2)
# check we can make a simple filter on title.
kw = default_parametrs.copy()
kw.update( portal_catalog.buildSQLQuery(
query_table = query_table,
title = 'source_organisation',
**kw) )
LOG('kw', 1, kw)
LOG('SQL', 1, testMethod(src__=1, **kw))
self.assertEqual( len(testMethod(**kw)), 1,
testMethod(src__=1, **kw) )
self.assertEqual( testMethod(**kw)[0]['uid'],
source_organisation.getUid(),
testMethod(src__=1, **kw) )
# check sort
kw = default_parametrs.copy()
kw.update(portal_catalog.buildSQLQuery(
query_table = query_table,
sort_on = [('id', 'ascending')],
**kw))
LOG('kw', 2, kw)
LOG('SQL', 2, testMethod(src__=1, **kw))
brains = testMethod(**kw)
self.assertEqual( len(brains), 2,
testMethod(src__=1, **kw))
self.assertFalse( brains[0]['id'] > brains[1]['id'],
testMethod(src__=1, **kw) )
# check related keys works
kw = default_parametrs.copy()
kw.update(portal_catalog.buildSQLQuery(
query_table = query_table,
destination_section_title = 'organisation_destination'),
**kw)
LOG('kw', 3, kw)
LOG('SQL', 3, testMethod(src__=1, **kw))
brains = testMethod(**kw)
self.assertEqual( len(brains), 1, testMethod(src__=1, **kw) )
self.assertEqual( brains[0]['uid'],
source_organisation.getUid(),
testMethod(src__=1, **kw) )
def test_19_SearchFolderWithNonAsciiCharacter(self):
person_module = self.getPersonModule()
......
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