[Erp5-report] r13719 - /erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Mar 27 16:35:47 CEST 2007


Author: seb
Date: Tue Mar 27 16:35:46 2007
New Revision: 13719

URL: http://svn.erp5.org?rev=13719&view=rev
Log:
- add test for related keys aliases

Modified:
    erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py

Modified: erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py?rev=13719&r1=13718&r2=13719&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py (original)
+++ erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py Tue Mar 27 16:35:46 2007
@@ -46,6 +46,7 @@
 from Products.ZSQLCatalog.ZSQLCatalog import HOT_REINDEXING_FINISHED_STATE,\
       HOT_REINDEXING_RECORDING_STATE, HOT_REINDEXING_DOUBLE_INDEXING_STATE
 from Products.CMFActivity.Errors import ActivityFlushError
+from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
 
 
 try:
@@ -1297,7 +1298,6 @@
     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()],
@@ -1487,6 +1487,10 @@
     path_list = [first_deleted_url,deleted_url,next_deleted_url]
     self.checkRelativeUrlNotInSQLPathList(path_list,connection_id=self.new_connection_id)
     self.checkRelativeUrlNotInSQLPathList(path_list,connection_id=self.original_connection_id)
+    # Make sure module are there
+    path_list = [module.getRelativeUrl()]
+    self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.new_connection_id)
+    self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.original_connection_id)
     
   def test_47_Unrestricted(self, quiet=quiet, run=run_all_test):
     """test unrestricted search/count results.
@@ -1654,6 +1658,43 @@
     self.assertEquals([select_], [x.getObject() for x in
                                    ctool(portal_type='Person', title='SELECT')])
 
+  def test_52_QueryAndTableAlias(self,quiet=quiet, run=run_all_test):
+    """
+    Make sure we can use aliases for tables wich will
+    be used by related keys. This allow in some particular
+    cases to decrease a lot the number of aliases
+    """
+    if not run: return
+    if not quiet:
+      message = 'Query And Table Alias'
+      ZopeTestCase._print('\n%s ' % message)
+      LOG('Testing... ',0,message)
+
+    org_a = self._makeOrganisation(title='abc',default_address_city='abc')
+    module = self.getOrganisationModule()
+    module.immediateReindexObject()
+    # First try without aliases
+    query1 = Query(parent_portal_type="Organisation")
+    query2 = Query(grand_parent_portal_type="Organisation Module")
+    complex_query = ComplexQuery(query1, query2, operator="AND")
+    self.failIfDifferentSet([org_a.getPath() + '/default_address'],
+        [x.path for x in self.getCatalogTool()(query=complex_query)])
+    # Then try without aliases
+    query1 = Query(parent_portal_type="Organisation", 
+                   table_alias_list=(("catalog" , "parent"),))
+    query2 = Query(grand_parent_portal_type="Organisation Module",
+                   table_alias_list=(("catalog" , "parent"), 
+                                    ("catalog", "grand_parent")))
+    complex_query = ComplexQuery(query1, query2, operator="AND")
+    self.failIfDifferentSet([org_a.getPath() + '/default_address'],
+        [x.path for x in self.getCatalogTool()(query=complex_query)])
+    sql_kw = self.getCatalogTool().buildSQLQuery(query=complex_query)
+    # Make sure we have the right list of aliases
+    table_alias_list = sql_kw["from_table_list"]
+    self.failIfDifferentSet((("catalog","catalog"),
+                             ("parent","catalog"),
+                             ("grand_parent","catalog")),
+                             table_alias_list)
 
 if __name__ == '__main__':
     framework()




More information about the Erp5-report mailing list