def test_roles(): db = current.db s3db = current.s3db suite = unittest.TestSuite() # Define Organisations orgs = ["Org-A", "Org-B", "Org-C", ] branches = [None, "Branch-A" ] create_role_test_data(orgs, branches) orgs = ["Org-A"] table_lookup = {"hrm_staff":"hrm_human_resource", "vol_volunteer":"hrm_human_resource", } for org in orgs: permission_matrix_filename = os.path.join(current.request.folder,"modules", "tests", "roles", current.deployment_settings.base.template, "%s_permission_matrix.csv" % org) permission_matrix_file = open(permission_matrix_filename, "rb") permission_matrix = csv.DictReader(permission_matrix_file) row_num = 1 # Header Row for test in permission_matrix: row_num = row_num + 1 #if row_num < 55 or row_num > 75: # continue table = test["table"] c = test["c"] f = test["f"] method = test["method"] uuid = test["uuid"] if table: db_table = s3db[table] elif c and f: tablename = "%s_%s" % (c, f) try: db_table = s3db[table_lookup.get(tablename, tablename)] except: db_table = None else: # No Table or C and F - probably header row row_num = row_num - 1 continue if uuid: #print "%s, %s, %s, %s" % (table,c,f, uuid) #print uuid record_id = db(db_table.uuid==uuid).select(db_table._id, limitby=(0, 1) ).first()[db_table._id] else: record_id = None for user, permission in test.items(): if user in ["table","c", "f", "method", "uuid"] or not user: continue test_role = TestRole() test_role.set(org = org, row_num = row_num, user = user, method = method, table = table, c = c, f = f, record_id = record_id, uuid = uuid, permission = permission) suite.addTest(test_role) return suite
def test_roles(): """ Test Permissions against Role Matrix File Documentation - http://eden.sahanafoundation.org/wiki/DeveloperGuidelines/Testing/Roles """ db = current.db s3db = current.s3db template = current.deployment_settings.base.template suite = unittest.TestSuite() # Get orgs and branches from template specific file. exec("from tests.roles." + template + ".test_orgs import get_org_branches") #from tests.roles.IFRC.test_orgs import get_org_branches (orgs, branches) = get_org_branches() create_role_test_data(orgs, branches) orgs = ["Org-A"] table_lookup = {"hrm_staff": "hrm_human_resource", "vol_volunteer": "hrm_human_resource", } for org in orgs: permission_matrix_filename = os.path.join(current.request.folder, "modules", "tests", "roles", template, "%s_permission_matrix.csv" % org) permission_matrix_file = open(permission_matrix_filename, "rb") permission_matrix = csv.DictReader(permission_matrix_file) row_num = 1 # Header Row for test in permission_matrix: row_num = row_num + 1 #if row_num < 55 or row_num > 75: # continue table = test["table"] c = test["c"] f = test["f"] method = test["method"] uuid = test["uuid"] if table: db_table = s3db[table] elif c and f: tablename = "%s_%s" % (c, f) try: db_table = s3db[table_lookup.get(tablename, tablename)] except: db_table = None else: # No Table or C and F - probably header row row_num = row_num - 1 continue if uuid: #print "%s, %s, %s, %s" % (table,c,f, uuid) #print uuid rec = db(db_table.uuid == uuid).select(db_table._id, limitby=(0, 1) ) if rec: record_id = rec.first()[db_table._id] else: record_id = None else: record_id = None for user, permission in test.items(): if user in ["table", "c", "f", "method", "uuid"] or not user: continue test_role = TestRole() test_role.set(org=org, row_num=row_num, user=user, method=method, table=table, c=c, f=f, record_id=record_id, uuid=uuid, permission=permission) suite.addTest(test_role) return suite
from tests.roles.create_role_test_data import * # Define Organisations orgs = [ "Org-A", "Org-B", "Org-C", ] branches = [None, "Branch-A"] create_role_test_data(orgs, branches)
def test_roles(): """ Test Permissions against Role Matrix File Documentation - http://eden.sahanafoundation.org/wiki/DeveloperGuidelines/Testing/Roles """ db = current.db s3db = current.s3db template = current.deployment_settings.base.template suite = unittest.TestSuite() # Get orgs and branches from template specific file. exec("from tests.roles." + template + ".test_orgs import get_org_branches") #from tests.roles.IFRC.test_orgs import get_org_branches (orgs, branches) = get_org_branches() create_role_test_data(orgs, branches) orgs = ["Org-A"] table_lookup = { "hrm_staff": "hrm_human_resource", "vol_volunteer": "hrm_human_resource", } for org in orgs: permission_matrix_filename = os.path.join( current.request.folder, "modules", "tests", "roles", template, "%s_permission_matrix.csv" % org) permission_matrix_file = open(permission_matrix_filename, "rb") permission_matrix = csv.DictReader(permission_matrix_file) row_num = 1 # Header Row for test in permission_matrix: row_num = row_num + 1 #if row_num < 55 or row_num > 75: # continue table = test["table"] c = test["c"] f = test["f"] method = test["method"] uuid = test["uuid"] if table: db_table = s3db[table] elif c and f: tablename = "%s_%s" % (c, f) try: db_table = s3db[table_lookup.get(tablename, tablename)] except: db_table = None else: # No Table or C and F - probably header row row_num = row_num - 1 continue if uuid: #print "%s, %s, %s, %s" % (table,c,f, uuid) #print uuid rec = db(db_table.uuid == uuid).select(db_table._id, limitby=(0, 1)) if rec: record_id = rec.first()[db_table._id] else: record_id = None else: record_id = None for user, permission in test.items(): if user in ["table", "c", "f", "method", "uuid"] or not user: continue test_role = TestRole() test_role.set(org=org, row_num=row_num, user=user, method=method, table=table, c=c, f=f, record_id=record_id, uuid=uuid, permission=permission) suite.addTest(test_role) return suite
def test_roles(): db = current.db s3db = current.s3db suite = unittest.TestSuite() # Define Organisations orgs = [ "Org-A", "Org-B", "Org-C", ] branches = [None, "Branch-A"] create_role_test_data(orgs, branches) orgs = ["Org-A"] table_lookup = { "hrm_staff": "hrm_human_resource", "vol_volunteer": "hrm_human_resource", } for org in orgs: permission_matrix_filename = os.path.join( current.request.folder, "modules", "tests", "roles", current.deployment_settings.base.template, "%s_permission_matrix.csv" % org) permission_matrix_file = open(permission_matrix_filename, "rb") permission_matrix = csv.DictReader(permission_matrix_file) row_num = 1 # Header Row for test in permission_matrix: row_num = row_num + 1 #if row_num < 55 or row_num > 75: # continue table = test["table"] c = test["c"] f = test["f"] method = test["method"] uuid = test["uuid"] if table: db_table = s3db[table] elif c and f: tablename = "%s_%s" % (c, f) try: db_table = s3db[table_lookup.get(tablename, tablename)] except: db_table = None else: # No Table or C and F - probably header row row_num = row_num - 1 continue if uuid: #print "%s, %s, %s, %s" % (table,c,f, uuid) #print uuid rec = db(db_table.uuid == uuid).select(db_table._id, limitby=(0, 1)) if rec: record_id = rec.first()[db_table._id] else: record_id = None else: record_id = None for user, permission in test.items(): if user in ["table", "c", "f", "method", "uuid"] or not user: continue test_role = TestRole() test_role.set(org=org, row_num=row_num, user=user, method=method, table=table, c=c, f=f, record_id=record_id, uuid=uuid, permission=permission) suite.addTest(test_role) return suite
from tests.roles.create_role_test_data import * # Define Organisations orgs = ["Org-1", "Org-2", "Org-3", ] branches = [ None, "Branch-A"] create_role_test_data(orgs,branches)