Commit 7a9f6e3c authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Update tests according to the changes in ERP5Catalog

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