Commit 973f12b3 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Update tests according to the changes in ERP5Catalog

Also, add test for migration in testERP5Catalog(as the first test to be run)
and migrate Catalog in afterSetup in testERP5CatalogSecurityUidOptimization.
parent 8a9f1ab8
...@@ -582,14 +582,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -582,14 +582,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
""" % {'query_table' : query_table} """ % {'query_table' : query_table}
portal_skins_custom = portal.portal_skins.custom portal_skins_custom = portal.portal_skins.custom
portal_skins_custom.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( portal_skins_custom.newContent(portal_type='SQL Method',
id='testMethod', id = 'testMethod',
title='', title = '',
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
arguments="\n".join([ 'from_table_list', arguments_src = "\n".join([ 'from_table_list',
'where_expression', 'where_expression',
'order_by_expression' ]), 'order_by_expression' ]),
template=sql_squeleton) src = sql_squeleton)
testMethod = portal_skins_custom['testMethod'] testMethod = portal_skins_custom['testMethod']
default_parametrs = {} default_parametrs = {}
...@@ -1476,14 +1476,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1476,14 +1476,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
""" """
for catalog, connection_id in ((original_catalog, original_connection_id), for catalog, connection_id in ((original_catalog, original_connection_id),
(new_catalog, self.new_erp5_sql_connection)): (new_catalog, self.new_erp5_sql_connection)):
catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( catalog.newContent(portal_type='SQL Method',
id='z_create_dummy_table', title='', arguments="", id='z_create_dummy_table', title='', arguments_src="",
connection_id=connection_id, connection_id=connection_id,
template=create_dummy_table_sql) src=create_dummy_table_sql)
catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( catalog.newContent(portal_type='SQL Method',
id='z0_drop_dummy_table', title='', arguments="", id='z0_drop_dummy_table', title='', arguments_src="",
connection_id=connection_id, connection_id=connection_id,
template=drop_summy_table_sql) src=drop_summy_table_sql)
# update catalog configuration and declare new ZSQLMethods # update catalog configuration and declare new ZSQLMethods
sql_clear_catalog_list = list(original_catalog.sql_clear_catalog) sql_clear_catalog_list = list(original_catalog.sql_clear_catalog)
...@@ -2389,6 +2389,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -2389,6 +2389,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# Add a new table to the catalog # Add a new table to the catalog
sql_catalog = self.portal.portal_catalog.getSQLCatalog() sql_catalog = self.portal.portal_catalog.getSQLCatalog()
sql_catalog.manage_setLocalRoles(user1, ['Author', 'Auditor', 'Manager'])
local_roles_table = "test_local_roles" local_roles_table = "test_local_roles"
...@@ -2400,22 +2401,22 @@ CREATE TABLE `%s` ( ...@@ -2400,22 +2401,22 @@ CREATE TABLE `%s` (
KEY `version` (`owner_reference`) KEY `version` (`owner_reference`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_create_%s' % local_roles_table, id = 'z_create_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=create_local_role_table_sql) src = create_local_role_table_sql)
drop_local_role_table_sql = """ drop_local_role_table_sql = """
DROP TABLE IF EXISTS %s DROP TABLE IF EXISTS %s
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z0_drop_%s' % local_roles_table, id = 'z0_drop_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=drop_local_role_table_sql) src = drop_local_role_table_sql)
catalog_local_role_sql = """ catalog_local_role_sql = """
REPLACE INTO REPLACE INTO
...@@ -2432,13 +2433,13 @@ VALUES ...@@ -2432,13 +2433,13 @@ VALUES
</dtml-if> </dtml-if>
</dtml-in> </dtml-in>
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_catalog_%s_list' % local_roles_table, id = 'z_catalog_%s_list' % local_roles_table,
title='', title = '',
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
arguments="\n".join(['uid', arguments_src = "\n".join(['uid',
'Base_getOwnerId']), 'Base_getOwnerId']),
template=catalog_local_role_sql) src = catalog_local_role_sql)
self.commit() self.commit()
current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list
...@@ -2571,6 +2572,7 @@ VALUES ...@@ -2571,6 +2572,7 @@ VALUES
# Add a new table to the catalog # Add a new table to the catalog
sql_catalog = self.portal.portal_catalog.getSQLCatalog() sql_catalog = self.portal.portal_catalog.getSQLCatalog()
sql_catalog.manage_setLocalRoles(user1, ['Author', 'Auditor', 'Manager'])
local_roles_table = "test_assignee_local_roles" local_roles_table = "test_assignee_local_roles"
...@@ -2584,22 +2586,22 @@ CREATE TABLE `%s` ( ...@@ -2584,22 +2586,22 @@ CREATE TABLE `%s` (
KEY `viewable_assignee_reference` (`viewable_assignee_reference`) KEY `viewable_assignee_reference` (`viewable_assignee_reference`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_create_%s' % local_roles_table, id = 'z_create_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=create_local_role_table_sql) src = create_local_role_table_sql)
drop_local_role_table_sql = """ drop_local_role_table_sql = """
DROP TABLE IF EXISTS %s DROP TABLE IF EXISTS %s
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z0_drop_%s' % local_roles_table, id = 'z0_drop_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=drop_local_role_table_sql) src = drop_local_role_table_sql)
catalog_local_role_sql = """ catalog_local_role_sql = """
REPLACE INTO REPLACE INTO
...@@ -2617,14 +2619,14 @@ VALUES ...@@ -2617,14 +2619,14 @@ VALUES
</dtml-if> </dtml-if>
</dtml-in> </dtml-in>
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_catalog_%s_list' % local_roles_table, id = 'z_catalog_%s_list' % local_roles_table,
title='', title = '',
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
arguments="\n".join(['uid', arguments_src = "\n".join(['uid',
'getAssignee', 'getAssignee',
'getViewPermissionAssignee']), 'getViewPermissionAssignee']),
template=catalog_local_role_sql) src = catalog_local_role_sql)
self.commit() self.commit()
current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list
...@@ -2729,6 +2731,7 @@ VALUES ...@@ -2729,6 +2731,7 @@ VALUES
# Add a new table to the catalog # Add a new table to the catalog
sql_catalog = self.portal.portal_catalog.getSQLCatalog() sql_catalog = self.portal.portal_catalog.getSQLCatalog()
sql_catalog.manage_setLocalRoles(user1, ['Author', 'Auditor', 'Manager'])
local_roles_table = "test_user_or_group_local_roles" local_roles_table = "test_user_or_group_local_roles"
...@@ -2742,22 +2745,22 @@ CREATE TABLE `%s` ( ...@@ -2742,22 +2745,22 @@ CREATE TABLE `%s` (
KEY `viewable_assignee_reference` (`viewable_assignee_reference`) KEY `viewable_assignee_reference` (`viewable_assignee_reference`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_create_%s' % local_roles_table, id = 'z_create_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=create_local_role_table_sql) src = create_local_role_table_sql)
drop_local_role_table_sql = """ drop_local_role_table_sql = """
DROP TABLE IF EXISTS %s DROP TABLE IF EXISTS %s
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z0_drop_%s' % local_roles_table, id = 'z0_drop_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=drop_local_role_table_sql) src = drop_local_role_table_sql)
catalog_local_role_sql = """ catalog_local_role_sql = """
REPLACE INTO REPLACE INTO
...@@ -2775,14 +2778,14 @@ VALUES ...@@ -2775,14 +2778,14 @@ VALUES
</dtml-if> </dtml-if>
</dtml-in> </dtml-in>
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_catalog_%s_list' % local_roles_table, id = 'z_catalog_%s_list' % local_roles_table,
title='', title = '',
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
arguments="\n".join(['uid', arguments_src = "\n".join(['uid',
'getAssignee', 'getAssignee',
'getViewPermissionAssignee']), 'getViewPermissionAssignee']),
template=catalog_local_role_sql) src = catalog_local_role_sql)
self.commit() self.commit()
current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list
...@@ -2983,6 +2986,7 @@ VALUES ...@@ -2983,6 +2986,7 @@ VALUES
# Add a new table to the catalog # Add a new table to the catalog
sql_catalog = self.portal.portal_catalog.getSQLCatalog() sql_catalog = self.portal.portal_catalog.getSQLCatalog()
sql_catalog.manage_setLocalRoles(user1, ['Author', 'Auditor', 'Manager'])
local_roles_table = "another_test_user_or_group_local_roles" local_roles_table = "another_test_user_or_group_local_roles"
...@@ -2994,22 +2998,22 @@ CREATE TABLE `%s` ( ...@@ -2994,22 +2998,22 @@ CREATE TABLE `%s` (
KEY `viewable_assignee_reference` (`viewable_assignee_reference`) KEY `viewable_assignee_reference` (`viewable_assignee_reference`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_create_%s' % local_roles_table, id = 'z_create_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=create_local_role_table_sql) src = create_local_role_table_sql)
drop_local_role_table_sql = """ drop_local_role_table_sql = """
DROP TABLE IF EXISTS %s DROP TABLE IF EXISTS %s
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z0_drop_%s' % local_roles_table, id = 'z0_drop_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=drop_local_role_table_sql) src = drop_local_role_table_sql)
catalog_local_role_sql = """ catalog_local_role_sql = """
REPLACE INTO REPLACE INTO
...@@ -3026,13 +3030,13 @@ VALUES ...@@ -3026,13 +3030,13 @@ VALUES
</dtml-if> </dtml-if>
</dtml-in> </dtml-in>
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_catalog_%s_list' % local_roles_table, id = 'z_catalog_%s_list' % local_roles_table,
title='', title = '',
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
arguments="\n".join(['uid', arguments_src = "\n".join(['uid',
'getViewPermissionAssignee']), 'getViewPermissionAssignee']),
template=catalog_local_role_sql) src = catalog_local_role_sql)
self.commit() self.commit()
current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list
...@@ -3223,22 +3227,22 @@ CREATE TABLE `%s` ( ...@@ -3223,22 +3227,22 @@ CREATE TABLE `%s` (
KEY `viewable_assignee_reference` (`viewable_assignee_reference`) KEY `viewable_assignee_reference` (`viewable_assignee_reference`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_create_%s' % local_roles_table, id = 'z_create_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=create_local_role_table_sql) src = create_local_role_table_sql)
drop_local_role_table_sql = """ drop_local_role_table_sql = """
DROP TABLE IF EXISTS %s DROP TABLE IF EXISTS %s
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z0_drop_%s' % local_roles_table, id = 'z0_drop_%s' % local_roles_table,
title='', title = '',
arguments="", arguments_src = "",
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
template=drop_local_role_table_sql) src = drop_local_role_table_sql)
catalog_local_role_sql = """ catalog_local_role_sql = """
REPLACE INTO REPLACE INTO
...@@ -3255,13 +3259,13 @@ VALUES ...@@ -3255,13 +3259,13 @@ VALUES
</dtml-if> </dtml-if>
</dtml-in> </dtml-in>
""" % local_roles_table """ % local_roles_table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_catalog_%s_list' % local_roles_table, id = 'z_catalog_%s_list' % local_roles_table,
title='', title = '',
connection_id='erp5_sql_connection', connection_id = 'erp5_sql_connection',
arguments="\n".join(['uid', arguments_src = "\n".join(['uid',
'getViewPermissionAssignee']), 'getViewPermissionAssignee']),
template=catalog_local_role_sql) src = catalog_local_role_sql)
self.commit() self.commit()
current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list current_sql_catalog_object_list = sql_catalog.sql_catalog_object_list
......
...@@ -73,12 +73,12 @@ CREATE TABLE alternate_roles_and_users ( ...@@ -73,12 +73,12 @@ CREATE TABLE alternate_roles_and_users (
'alternate_roles_and_users'] 'alternate_roles_and_users']
# Configure sql method to insert this table # Configure sql method to insert this table
sql_catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod( sql_catalog.newContent(portal_type='SQL Method',
id='z_catalog_alternate_roles_and_users_list', id='z_catalog_alternate_roles_and_users_list',
title='', title='',
connection_id='erp5_sql_connection', connection_id='erp5_sql_connection',
arguments="\n".join(['uid', 'alternate_security_uid']), arguments_src="\n".join(['uid', 'alternate_security_uid']),
template="""REPLACE INTO alternate_roles_and_users VALUES src="""REPLACE INTO alternate_roles_and_users VALUES
<dtml-in prefix="loop" expr="_.range(_.len(uid))"> <dtml-in prefix="loop" expr="_.range(_.len(uid))">
( <dtml-sqlvar expr="uid[loop_item]" type="int">, ( <dtml-sqlvar expr="uid[loop_item]" type="int">,
<dtml-sqlvar expr="alternate_security_uid[loop_item]" type="int" optional> <dtml-sqlvar expr="alternate_security_uid[loop_item]" type="int" optional>
......
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