desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Test handling of failed explicit reference'
def testFailedReferenceExplicit(self):
xmlstr = '\n<s3xml>\n <resource name="org_office">\n <data field="name">FRTestOffice1</data>\n <reference field="organisation_id">\n <resource name="org_organisation" uuid="TROX...
'Test handling of failed inline reference'
def testFailedReferenceInline(self):
xmlstr = '\n<s3xml>\n <resource name="org_office">\n <data field="name">FRTestOffice2</data>\n <reference field="organisation_id">\n <resource name="org_organisation" uuid="TROY...
'Test match with primary/secondary field'
def testMatch(self):
assertEqual = self.assertEqual deduplicate = S3Duplicate(primary=('name',), secondary=('secondary',)) item = S3ImportItem(self.job) item.table = current.db.dedup_test ids = self.ids item.id = None item.method = item.METHOD.CREATE item.data = Storage(name='Test0') deduplicate(item) ...
'Test default behavior'
def testDefaults(self):
assertEqual = self.assertEqual deduplicate = S3Duplicate() item = S3ImportItem(self.job) item.table = current.db.dedup_test ids = self.ids item.id = None item.method = item.METHOD.CREATE item.data = Storage(name='Test0') deduplicate(item) assertEqual(item.id, ids['TEST0']) as...
'Test S3Duplicate exceptions for nonexistent fields'
def testExceptions(self):
assertRaises = self.assertRaises item = S3ImportItem(self.job) item.table = current.db.dedup_test deduplicate = S3Duplicate(primary=('nonexistent',)) item.id = None item.method = item.METHOD.CREATE item.data = Storage(name='Test0') with assertRaises(SyntaxError): deduplicate(item...
'Verify that create-postprocess does not overwrite imported modified_on'
def testMtimeImport(self):
s3db = current.s3db assertEqual = self.assertEqual mtime = datetime.datetime(1988, 8, 13, 10, 0, 0) xmlstr = ('\n<s3xml>\n <resource name="org_facility" modified_on="%(mtime)s" uuid="MTFAC">\n <data field="name">MtimeTestOffice</data>\n ...
'Test processing emails to individual persons'
def testProcessEmailToPerson(self):
s3db = current.s3db resource = s3db.resource('pr_person', uid=['MsgTestPerson1', 'MsgTestPerson2']) rows = resource.select(['pe_id'], as_rows=True) self.sent = [] outbox = s3db.msg_outbox for row in rows: outbox_id = outbox.insert(pe_id=row.pe_id, message_id=self.message_id) msg = cu...
'Test processing emails to groups'
def testProcessEmailToGroup(self):
s3db = current.s3db resource = s3db.resource('pr_group', uid=['MsgTestGroup']) rows = resource.select(['pe_id'], as_rows=True) self.sent = [] outbox = s3db.msg_outbox for row in rows: outbox_id = outbox.insert(pe_id=row.pe_id, message_id=self.message_id) msg = current.msg msg.sen...
'Test processing emails to organisations'
def testProcessEmailToOrganisation(self):
s3db = current.s3db resource = s3db.resource('org_organisation', uid=['MsgTestOrg']) rows = resource.select(['pe_id'], as_rows=True) self.sent = [] outbox = s3db.msg_outbox for row in rows: outbox_id = outbox.insert(pe_id=row.pe_id, message_id=self.message_id) msg = current.msg m...
'Test sending to a non-existent person'
def testProcessingEmailToInvalidPerson(self):
s3db = current.s3db resource = s3db.resource('pr_person', uid=['MsgTestPerson1']) row = resource.select(['pe_id'], as_rows=True).first() self.sent = [] outbox = s3db.msg_outbox outbox_id = outbox.insert(pe_id=row.pe_id, message_id=self.message_id) outbox_id = outbox.insert(pe_id=None, messag...
'Test sending to a group that contains an invalid membership'
def testProcessingEmailToInvalidPersonInGroup(self):
db = current.db s3db = current.s3db ptable = s3db.pr_person gtable = s3db.pr_group mtable = s3db.pr_group_membership query = ((((gtable.uuid == 'MsgTestGroup') & (mtable.group_id == gtable.id)) & (ptable.id == mtable.person_id)) & (ptable.uuid == 'MsgTestPerson1')) membership = db(query).sel...
'Test processing emails to an organisation with error during send'
def testProcessEmailToOrganisationSendError(self):
s3db = current.s3db resource = s3db.resource('org_organisation', uid=['MsgTestOrg']) rows = resource.select(['pe_id'], as_rows=True) self.sent = [] outbox = s3db.msg_outbox for row in rows: outbox_id = outbox.insert(pe_id=row.pe_id, message_id=self.message_id) msg = current.msg m...
'Test processing emails to an organisation with exception during send'
def testProcessEmailToGroupSendException(self):
s3db = current.s3db resource = s3db.resource('pr_group', uid=['MsgTestGroup']) rows = resource.select(['pe_id'], as_rows=True) self.sent = [] outbox = s3db.msg_outbox for row in rows: outbox_id = outbox.insert(pe_id=row.pe_id, message_id=self.message_id) msg = current.msg msg.sen...
'Test inhibition of failing messages after max_send_retries'
def testProcessEmailToPersonMaxRetries(self):
MAX_SEND_RETRIES = current.deployment_settings.get_msg_max_send_retries() if (MAX_SEND_RETRIES is None): return s3db = current.s3db resource = s3db.resource('pr_person', uid=['MsgTestPerson1']) row = resource.select(['pe_id'], as_rows=True).first() self.sent = [] outbox = s3db.msg_ou...
'Dummy send mechanism'
def send_email(self, recipient, *args, **kwargs):
if (recipient in ('test1@example.com', 'test2@example.com')): self.sent.append(recipient) return True else: return False
'Dummy send mechanism that fails for 1 recipient'
def send_email_error(self, recipient, *args, **kwargs):
if (recipient == 'test2@example.com'): self.sent.append(recipient) return True else: return False
'Dummy send mechanism that crashes for 1 recipient'
def send_email_exception(self, recipient, *args, **kwargs):
if (recipient == 'test1@example.com'): self.sent.append(recipient) return True elif (recipient == 'test2@example.com'): raise RuntimeError else: return False
'Test selection of a leaf node'
def testSelectLeaf(self):
menu = self.menu items = self.items assertTrue = self.assertTrue assertIsNone = self.assertIsNone menu.select(tag='a11') assertTrue(menu.selected) assertTrue(items['a1'].selected) assertTrue(items['a11'].selected) assertIsNone(items['a12'].selected) assertIsNone(items['a2'].selec...
'Test selection of a branch'
def testSelectBranch(self):
menu = self.menu items = self.items assertTrue = self.assertTrue assertIsNone = self.assertIsNone menu.select(tag='a2') assertTrue(menu.selected) assertIsNone(items['a1'].selected) assertIsNone(items['a11'].selected) assertIsNone(items['a12'].selected) assertTrue(items['a2'].sele...
'Test selection of specific nodes'
def testSelectSpecificNode(self):
menu = self.menu items = self.items assertTrue = self.assertTrue assertIsNone = self.assertIsNone items['a2'].select() assertTrue(menu.selected) assertIsNone(items['a1'].selected) assertIsNone(items['a11'].selected) assertIsNone(items['a12'].selected) assertTrue(items['a2'].selec...
'Test selection with non-existent tag'
def testSelectNonexistentTag(self):
menu = self.menu items = self.items assertTrue = self.assertTrue assertIsNone = self.assertIsNone menu.select(tag='a21') assertTrue(menu.selected) assertIsNone(items['a1'].selected) assertIsNone(items['a11'].selected) assertIsNone(items['a12'].selected) assertTrue(items['a2'].sel...
'Test deselection'
def testDeselectAll(self):
menu = self.menu items = self.items assertTrue = self.assertTrue assertIsNone = self.assertIsNone menu.select(tag='a21') assertTrue(menu.selected) assertIsNone(items['a1'].selected) assertIsNone(items['a11'].selected) assertIsNone(items['a12'].selected) assertTrue(items['a2'].sel...
'Test consecutive manual selects'
def testSwitchSelection(self):
menu = self.menu items = self.items assertTrue = self.assertTrue assertIsNone = self.assertIsNone menu.select(tag='a11') assertTrue(menu.selected) assertTrue(items['a1'].selected) assertTrue(items['a11'].selected) assertIsNone(items['a12'].selected) assertIsNone(items['a2'].selec...
'Test if system roles are present'
def testSystemRoles(self):
sr = current.auth.get_system_roles() assertTrue = self.assertTrue assertTrue(isinstance(sr, Storage)) assertTrue(('ADMIN' in sr)) assertTrue((sr.ADMIN is not None)) assertTrue(('AUTHENTICATED' in sr)) assertTrue((sr.AUTHENTICATED is not None)) assertTrue(('ANONYMOUS' in sr)) assertTr...
'Test user account identification by email'
def testGetUserIDByEmail(self):
user_id = current.auth.s3_get_user_id('normaluser@example.com') self.assertTrue((user_id is not None))
'Test s3_impersonate'
def testImpersonate(self):
auth = current.auth session = current.session sr = auth.get_system_roles() ADMIN = sr.ADMIN ANONYMOUS = sr.ANONYMOUS assertTrue = self.assertTrue assertFalse = self.assertFalse assertRaises = self.assertRaises auth.s3_impersonate('admin@example.com') assertTrue(auth.s3_logged_in(...
'Test authorization failure for RFC1945/2617 compliance'
def testFail(self):
auth = current.auth f = auth.permission.format assertEqual = self.assertEqual assertIn = self.assertIn try: auth.permission.format = 'html' auth.s3_impersonate(None) try: auth.permission.fail() except HTTP as e: assertEqual(e.status, 303) ...
'Test set_roles with policy 3'
def testSetRolesPolicy3(self):
auth = current.auth settings = current.deployment_settings settings.security.policy = 3 auth.permission = S3Permission(auth) assertEqual = self.assertEqual assertTrue = self.assertTrue auth.s3_impersonate('normaluser@example.com') realms = auth.user.realms.keys() assertEqual(len(real...
'Test set_roles with policy 4'
def testSetRolesPolicy4(self):
auth = current.auth settings = current.deployment_settings settings.security.policy = 4 auth.permission = S3Permission(auth) assertEqual = self.assertEqual assertTrue = self.assertTrue auth.s3_impersonate('normaluser@example.com') realms = auth.user.realms.keys() assertTrue((2 in rea...
'Test set_roles with policy 5'
def testSetRolesPolicy5(self):
auth = current.auth settings = current.deployment_settings settings.security.policy = 5 auth.permission = S3Permission(auth) assertEqual = self.assertEqual assertTrue = self.assertTrue auth.s3_impersonate('normaluser@example.com') realms = auth.user.realms.keys() assertTrue((2 in rea...
'Test set_roles with policy 6'
def testSetRolesPolicy6(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings settings.security.policy = 6 auth.permission = S3Permission(auth) assertEqual = self.assertEqual assertTrue = self.assertTrue try: role = auth.s3_create_role('Example Role', uid='TESTROLE') ...
'Test set_roles with policy 7'
def testSetRolesPolicy7(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings settings.security.policy = 7 auth.permission = S3Permission(auth) assertEqual = self.assertEqual assertTrue = self.assertTrue try: role = auth.s3_create_role('Example Role', uid='TESTROLE') ...
'Test set_roles with policy 8'
def testSetRolesPolicy8(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings settings.security.policy = 8 auth.permission = S3Permission(auth) assertEqual = self.assertEqual assertTrue = self.assertTrue assertFalse = self.assertFalse try: role = auth.s3_create_role('Test ...
'Test role assignment to a user'
def testAssignRole(self):
db = current.db auth = current.auth UUID1 = 'TESTAUTOCREATEDROLE1' UUID2 = 'TESTAUTOCREATEDROLE2' uuids = [UUID1, UUID2] table = auth.settings.table_group query1 = ((table.deleted != True) & (table.uuid == UUID1)) query2 = ((table.deleted != True) & (table.uuid == UUID2)) assertEqual...
'Test role lookup for a user'
def testGetRoles(self):
auth = current.auth UUID = 'TESTAUTOCREATEDROLE' role_id = auth.s3_create_role(UUID, uid=UUID) assertTrue = self.assertTrue assertFalse = self.assertFalse try: auth.s3_impersonate('normaluser@example.com') user_id = auth.user.id auth.s3_assign_role(user_id, role_id, for_p...
'Test ownership required for controller'
def testOwnershipRequiredController(self):
auth = current.auth permission = auth.permission deployment_settings = current.deployment_settings policies = {1: False, 2: False, 3: True, 4: True, 5: True, 6: True, 7: True, 8: True, 0: True} current_policy = deployment_settings.get_security_policy() assertTrue = self.assertTrue assertFals...
'Test ownership required for table'
def testOwnershipRequiredTable(self):
auth = current.auth permission = auth.permission deployment_settings = current.deployment_settings policies = {1: False, 2: False, 3: False, 4: False, 5: True, 6: True, 7: True, 8: True, 0: True} current_policy = deployment_settings.get_security_policy() assertTrue = self.assertTrue assertFa...
'Test session ownership methods'
def testSessionOwnership(self):
db = current.db auth = current.auth s3db = current.s3db ptable = s3db.pr_person otable = s3db.org_organisation assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_impersonate(None) auth.s3_clear_session_ownership() auth.s3_make_session_owner(ptable, 1) assertF...
'Test ownership for a public record'
def testOwnershipPublicRecord(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_clear_session_ownership() table = self.table record_id = self.record_id s3_impersonate('admin@example.com') assertTrue(...
'Test ownership for an Admin-owned record'
def testOwnershipAdminOwnedRecord(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_clear_session_ownership() table = self.table record_id = self.record_id user_id = auth.s3_get_user_id('admin@example.com') ...
'Test ownership for a user-owned record'
def testOwnershipUserOwnedRecord(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_clear_session_ownership() table = self.table record_id = self.record_id user_id = auth.s3_get_user_id('normaluser@example.c...
'Test ownership for a collectively owned record'
def testOwnershipGroupOwnedRecord(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_clear_session_ownership() table = self.table record_id = self.record_id sr = auth.get_system_roles() user_id = auth.s3_...
'Test group-ownership for an entity-owned record'
def testOwnershipOrganisationOwnedRecord(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_clear_session_ownership() table = self.table record_id = self.record_id org = current.s3db.pr_get_pe_id('org_organisation',...
'Test override of owners in is_owner'
def testOwnershipOverride(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_clear_session_ownership() table = self.table record_id = self.record_id org = current.s3db.pr_get_pe_id('org_organisation',...
'Test lookup of record owners'
def testGetOwners(self):
auth = current.auth s3_impersonate = auth.s3_impersonate is_owner = auth.permission.is_owner assertEqual = self.assertEqual auth.s3_clear_session_ownership() table = self.table record_id = self.record_id user = auth.s3_get_user_id('admin@example.com') role = self.role_id org = cu...
'Test lambda to compute the required ACL'
def testRequiredACL(self):
p = current.auth.permission assertEqual = self.assertEqual assertEqual(p.required_acl(['read']), p.READ) assertEqual(p.required_acl(['create']), p.CREATE) assertEqual(p.required_acl(['update']), p.UPDATE) assertEqual(p.required_acl(['delete']), p.DELETE) assertEqual(p.required_acl(['create',...
'Test lambda to compute the most permissive ACL'
def testMostPermissive(self):
p = current.auth.permission self.assertEqual(p.most_permissive([(p.NONE, p.READ), (p.READ, p.READ)]), (p.READ, p.READ)) self.assertEqual(p.most_permissive([(p.NONE, p.ALL), (p.CREATE, p.ALL), (p.READ, p.ALL)]), ((p.READ | p.CREATE), p.ALL))
'Test lambda to compute the most restrictive ACL'
def testMostRestrictive(self):
p = current.auth.permission self.assertEqual(p.most_restrictive([(p.NONE, p.READ), (p.READ, p.READ)]), (p.NONE, p.READ)) self.assertEqual(p.most_restrictive([(p.CREATE, p.ALL), (p.READ, p.READ)]), (p.NONE, p.READ))
'Test update/delete of a controller ACL'
def testUpdateControllerACL(self):
auth = current.auth table = auth.permission.table self.assertNotEqual(table, None) group_id = auth.s3_create_role('Test Role', uid='TEST') acl_id = None assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue assertFalse = self.assertFalse ...
'Test update/delete of a table-ACL'
def testUpdateTableACL(self):
auth = current.auth table = auth.permission.table self.assertNotEqual(table, None) group_id = auth.s3_create_role('Test Role', uid='TEST') acl_id = None assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue assertFalse = self.assertFalse ...
'Test permission check with policy 1'
def testPolicy1(self):
auth = current.auth current.deployment_settings.security.policy = 1 auth.permission = S3Permission(auth) has_permission = auth.s3_has_permission tablename = 'org_permission_test' assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_impersonate(None) permitted = has_per...
'Test permission check with policy 3'
def testPolicy3(self):
auth = current.auth current.deployment_settings.security.policy = 3 auth.permission = S3Permission(auth) has_permission = auth.s3_has_permission c = 'org' f = 'permission_test' tablename = 'org_permission_test' assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_i...
'Test permission check with policy 4'
def testPolicy4(self):
auth = current.auth current.deployment_settings.security.policy = 4 auth.permission = S3Permission(auth) has_permission = auth.s3_has_permission c = 'org' f = 'permission_test' tablename = 'org_permission_test' assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_i...
'Test permission check with policy 5'
def testPolicy5(self):
auth = current.auth current.deployment_settings.security.policy = 5 auth.permission = S3Permission(auth) has_permission = auth.s3_has_permission accessible_url = auth.permission.accessible_url c = 'org' f = 'permission_test' tablename = 'org_permission_test' assertEqual = self.assert...
'Test permission check with policy 6'
def testPolicy6(self):
auth = current.auth current.deployment_settings.security.policy = 6 auth.permission = S3Permission(auth) has_permission = auth.s3_has_permission c = 'org' f = 'permission_test' tablename = 'org_permission_test' assertTrue = self.assertTrue assertFalse = self.assertFalse auth.s3_i...
'Test permission check with policy 7'
def testPolicy7(self):
auth = current.auth s3db = current.s3db current.deployment_settings.security.policy = 7 auth.permission = S3Permission(auth) has_permission = auth.s3_has_permission c = 'org' f = 'permission_test' tablename = 'org_permission_test' assertTrue = self.assertTrue assertFalse = self.a...
'Test permission check with policy 8'
def testPolicy8(self):
auth = current.auth s3db = current.s3db current.deployment_settings.security.policy = 8 auth.permission = S3Permission(auth) user = auth.s3_user_pe_id(auth.s3_get_user_id('normaluser@example.com')) has_permission = auth.s3_has_permission c = 'org' f = 'permission_test' tablename = 'o...
'Test accessible query with policy 3'
def testPolicy3(self):
auth = current.auth current.deployment_settings.security.policy = 3 auth.permission = S3Permission(auth) accessible_query = auth.s3_accessible_query c = 'org' f = 'permission_test' table = current.s3db.org_permission_test assertEqual = self.assertEqual ALL = (table.id > 0) NONE =...
'Test accessible query with policy 4'
def testPolicy4(self):
auth = current.auth current.deployment_settings.security.policy = 4 auth.permission = S3Permission(auth) accessible_query = auth.s3_accessible_query c = 'org' f = 'permission_test' table = current.s3db.org_permission_test assertEqual = self.assertEqual ALL = (table.id > 0) NONE =...
'Test accessible query with policy 5'
def testPolicy5(self):
auth = current.auth current.deployment_settings.security.policy = 5 auth.permission = S3Permission(auth) accessible_query = auth.s3_accessible_query c = 'org' f = 'permission_test' table = current.s3db.org_permission_test assertEqual = self.assertEqual ALL = (table.id > 0) NONE =...
'Test accessible query with policy 6'
def testPolicy6(self):
auth = current.auth current.deployment_settings.security.policy = 6 auth.permission = S3Permission(auth) accessible_query = auth.s3_accessible_query c = 'org' f = 'permission_test' table = current.s3db.org_permission_test assertEqual = self.assertEqual ALL = (table.id > 0) NONE =...
'Test accessible query with policy 7'
def testPolicy7(self):
auth = current.auth s3db = current.s3db current.deployment_settings.security.policy = 7 auth.permission = S3Permission(auth) accessible_query = auth.s3_accessible_query c = 'org' f = 'permission_test' table = current.s3db.org_permission_test assertEqual = self.assertEqual ALL = (...
'Test accessible query with policy 8'
def testPolicy8(self):
s3db = current.s3db auth = current.auth current.deployment_settings.security.policy = 8 auth.permission = S3Permission(auth) accessible_query = auth.s3_accessible_query c = 'org' f = 'permission_test' table = current.s3db.org_permission_test assertEqual = self.assertEqual ALL = (...
'Test delegation of a role'
def testRoleDelegation(self):
s3db = current.s3db auth = current.auth current.deployment_settings.security.policy = 8 auth.permission = S3Permission(auth) auth.s3_impersonate('normaluser@example.com') user = auth.user.pe_id org1 = self.org[0] org2 = self.org[1] org3 = self.org[2] pr_add_affiliation = s3db.pr_...
'Test whether a new record is unapproved by default'
def testRecordApprovedBy(self):
db = current.db auth = current.auth s3db = current.s3db settings = current.deployment_settings try: settings.auth.record_approval = True auth.s3_impersonate('admin@example.com') otable = s3db.org_organisation otable.approved_by.default = None org = Storage(nam...
'Test requires_approval settings'
def testRequiresApproval(self):
s3db = current.s3db settings = current.deployment_settings approval = settings.get_auth_record_approval() tables = settings.get_auth_record_approval_required_for() org_approval = s3db.get_config('org_organisation', 'requires_approval') approval_required = current.auth.permission.requires_approva...
'Test whether default approver is set if current user has permission to approve records in a table'
def testSetDefaultApprover(self):
auth = current.auth acl = auth.permission AUTHENTICATED = auth.get_system_roles().AUTHENTICATED otable = current.s3db.org_organisation otable.approved_by.default = None assertEqual = self.assertEqual acl.set_default_approver(otable, force=True) assertEqual(otable.approved_by.default, 0) ...
'Test record approval including components'
def testRecordApprovalWithComponents(self):
db = current.db auth = current.auth s3db = current.s3db settings = current.deployment_settings settings.auth.record_approval = True self.approved_org = None def org_onapprove_test(record): self.approved_org = record.id org_onapprove = s3db.get_config('org_organisation', 'onapprov...
'Test record approval without components'
def testRecordApprovalWithoutComponents(self):
db = current.db auth = current.auth s3db = current.s3db settings = current.deployment_settings settings.auth.record_approval = True otable = s3db.org_organisation otable_requires_approval = s3db.get_config(otable, 'requires_approval', None) s3db.configure(otable, requires_approval=True) ...
'Test has_permission with record approval'
def testHasPermissionWithRecordApproval(self):
db = current.db auth = current.auth acl = auth.permission s3db = current.s3db settings = current.deployment_settings has_permission = auth.s3_has_permission AUTHENTICATED = auth.get_system_roles().AUTHENTICATED approval = settings.get_auth_record_approval() approval_required = settin...
'Test accessible_query with record approval'
def testAccessibleQueryWithRecordApproval(self):
db = current.db auth = current.auth acl = auth.permission s3db = current.s3db settings = current.deployment_settings accessible_query = auth.s3_accessible_query session = current.session table = s3db.pr_person otable = s3db.org_organisation approval = settings.get_auth_record_app...
'Test table-specific realm_entity hook'
def testTableSpecificRealmEntity(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' s3db.configure(tname, realm_entity=self.realm_entity) auth.s3_set_record_owner(otable, record, force_update=True) self...
'Test global realm_entity hook'
def testGlobalRealmEntity(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity auth.s3_set_record_owner(otable, record, force_update=True) self.assert...
'Check whether global realm_entity hook overrides any table-specific setting'
def testRealmEntityOverride(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' s3db.configure(tname, realm_entity=self.realm_entity) settings.auth.realm_entity = self.realm_entity_override auth.s3_...
'Test the realm entity can be set for a record'
def testSetRealmEntityWithRecord(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity assertEqual = self.assertEqual auth.set_realm_entity(otable, record, fo...
'Test whether the realm entity of the component updates automatically'
def testSetRealmEntityWithRealmComponent(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings realm_components = s3db.get_config('org_organisation', 'realm_components', 'none') s3db.configure('org_organisation', realm_components=['office']) assertEqual = self.assertEqual try: otable = s3db.org_orga...
'Test the realm entity can be set for a record ID'
def testSetRealmEntityWithRecordID(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity assertEqual = self.assertEqual auth.set_realm_entity(otable, self.org_i...
'Test the realm entity can be set for a list of record IDs'
def testSetRealmEntityWithRecordIDList(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity assertEqual = self.assertEqual auth.set_realm_entity(otable, [self.org_...
'Test the realm entity can be set for a query'
def testSetRealmEntityWithQuery(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation record = otable[self.org_id] tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity assertEqual = self.assertEqual query = (otable.id == self.org_id) a...
'Test that realm entity can be overridden by call'
def testSetRealmEntityWithQueryAndOverride(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity assertEqual = self.assertEqual query = (otable.id == self.org_id) auth.set_realm_entity(otable, quer...
'Test that realm entity can be set to None'
def testSetRealmEntityWithQueryAndOverrideNone(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings otable = s3db.org_organisation tname = 'org_organisation' settings.auth.realm_entity = self.realm_entity assertEqual = self.assertEqual query = (otable.id == self.org_id) auth.set_realm_entity(otable, quer...
'Test that realm entity gets set in super-entity'
def testUpdateSharedFields(self):
s3db = current.s3db auth = current.auth settings = current.deployment_settings ftable = s3db.org_office stable = s3db.org_site assertEqual = self.assertEqual row = ftable[self.office_id] row.update_record(realm_entity=row['pe_id']) site_id = row['site_id'] auth.update_shared_fiel...
'Dummy method for hook testing'
def realm_entity(self, table, row):
self.owned_record = (table._tablename, row.id) return 5
'Dummy method for hook testing'
def realm_entity_override(self, table, row):
self.owned_record = 'checked' return 6
'Test linking a user account to a new person record'
def testLinkToNewPerson(self):
auth = current.auth s3db = current.s3db assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue assertFalse = self.assertFalse utable = auth.settings.table_user user = Storage(first_name='TestLTPR2', last_name='User', email='testltpr2@example.com'...
'Test linking a user account to a pre-existing person record'
def testLinkToExistingPerson(self):
auth = current.auth s3db = current.s3db assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue assertFalse = self.assertFalse utable = auth.settings.table_user user = Storage(first_name='TestLTPR', last_name='User', email='testltpr@example.com', ...
'Test update of a pre-linked person record upon user account update'
def testUpdateLinkedPerson(self):
auth = current.auth s3db = current.s3db assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue assertFalse = self.assertFalse utable = auth.settings.table_user user = Storage(first_name='TestLTPR', last_name='User', email='testltpr@example.com', ...
'Test s3_link_to_person with multiple user accounts'
def testMultipleUserRecords(self):
auth = current.auth s3db = current.s3db assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue utable = auth.settings.table_user users = [] user1 = Storage(first_name='TestLTPR1', last_name='User', email='testltpr1@example.com', password='XYZ') ...
'Test get_assigned_roles'
def testGetAssignedRoles(self):
assertEqual = self.assertEqual assertNotEqual = self.assertNotEqual assertTrue = self.assertTrue assertFalse = self.assertFalse get_assigned_roles = self.rm.get_assigned_roles org_id = self.org_id user_id = self.user_id roles = get_assigned_roles(entity_id=org_id) assertTrue((user_id...
'Test that before/after works'
def testUpdateRoles(self):
before = ('staff_reader', 'project_editor') after = ('survey_reader',) assertEqual = self.assertEqual assertTrue = self.assertTrue rm = self.rm get_assigned_roles = rm.get_assigned_roles update_roles = rm.update_roles org_id = self.org_id user_id = self.user_id update_roles(user_...
'Test a New Staff with existing Site &/or Home Address'
def _testStaffWithExistingLocations(self, site, address):
db = current.db s3db = current.s3db gtable = s3db.gis_location if site: record = Storage(name='Test Site Location') site_location_id = gtable.insert(**record) self.assertNotEqual(site_location_id, None) record['id'] = site_location_id s3db.onaccept(gtable, r...
'Test a Staff which has a Site assigned after creation'
def _testStaffUpdateFromSite(self, address):
db = current.db s3db = current.s3db gtable = s3db.gis_location record = Storage(name='Test Site Location') site_location_id = gtable.insert(**record) self.assertNotEqual(site_location_id, None) record['id'] = site_location_id s3db.onaccept(gtable, record, method='create') otabl...
'Test a New Volunteer with existing Site &/or Home Address'
def _testVolWithExistingLocations(self, site, address):
db = current.db s3db = current.s3db gtable = s3db.gis_location ptable = s3db.pr_person record = Storage(first_name='Test', last_name='Person') person_id = ptable.insert(**record) self.assertNotEqual(person_id, None) record['id'] = person_id s3db.update_super(ptable, record) s3db....
'Test a Volunteer which has a Home Address added after creation'
def _testVolUpdateFromPersonAddress(self, site):
db = current.db s3db = current.s3db gtable = s3db.gis_location if site: record = Storage(name='Test Site Location') site_location_id = gtable.insert(**record) self.assertNotEqual(site_location_id, None) record['id'] = site_location_id s3db.onaccept(gtable, r...
'Test that a Volunteer can get their location_id updated from a New Home Address: with just "person_id"'
def testVolUpdateFromPersonAddress1(self):
current.deployment_settings.hrm.location_vol = 'person_id' (row, address_location_id, site_location_id) = self._testVolUpdateFromPersonAddress(site=False) self.assertEqual(row.location_id, address_location_id)
'Test that a Volunteer can get their location_id updated from a New Home Address: with just "person_id"'
def testVolUpdateFromPersonAddress2(self):
current.deployment_settings.hrm.location_vol = 'person_id' (row, address_location_id, site_location_id) = self._testVolUpdateFromPersonAddress(site=True) self.assertEqual(row.location_id, address_location_id)
'Test that a Volunteer can get their location_id updated from a New Home Address: with "person_id" 1st'
def testVolUpdateFromPersonAddress3(self):
current.deployment_settings.hrm.location_vol = ('person_id', 'site_id') (row, address_location_id, site_location_id) = self._testVolUpdateFromPersonAddress(site=False) self.assertEqual(row.location_id, address_location_id)
'Test that a Volunteer can get their location_id updated from a New Home Address: with "person_id" 1st'
def testVolUpdateFromPersonAddress4(self):
current.deployment_settings.hrm.location_vol = ('person_id', 'site_id') (row, address_location_id, site_location_id) = self._testVolUpdateFromPersonAddress(site=True) self.assertEqual(row.location_id, address_location_id)
'Test that a Volunteer can get their location_id updated from a New Home Address: with "person_id" 2nd'
def testVolUpdateFromPersonAddress5(self):
current.deployment_settings.hrm.location_vol = ('site_id', 'person_id') (row, address_location_id, site_location_id) = self._testVolUpdateFromPersonAddress(site=False) self.assertEqual(row.location_id, address_location_id)
'Test that a Volunteer can get their location_id updated from a New Home Address: with "person_id" 2nd'
def testVolUpdateFromPersonAddress6(self):
current.deployment_settings.hrm.location_vol = ('site_id', 'person_id') (row, address_location_id, site_location_id) = self._testVolUpdateFromPersonAddress(site=True) self.assertEqual(row.location_id, site_location_id)