'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 = current.s3db.pr_get_pe_id('org_organisation', 1)
    (e, r, u) = auth.permission.get_owners(table, None)
    assertEqual(e, None)
    assertEqual(r, None)
    assertEqual(u, None)
    (e, r, u) = auth.permission.get_owners(None, record_id)
    assertEqual(e, None)
    assertEqual(r, None)
    assertEqual(u, None)
    (e, r, u) = auth.permission.get_owners(None, None)
    assertEqual(e, None)
    assertEqual(r, None)
    assertEqual(u, None)
    (e, r, u) = auth.permission.get_owners(table, record_id)
    assertEqual(e, None)
    assertEqual(r, None)
    assertEqual(u, None)
    current.db((table.id == record_id)).update(owned_by_user=user, owned_by_group=role, realm_entity=org)
    (e, r, u) = auth.permission.get_owners(table, record_id)
    assertEqual(e, org)
    assertEqual(r, role)
    assertEqual(u, user)
    (e, r, u) = auth.permission.get_owners(table._tablename, record_id)
    assertEqual(e, org)
    assertEqual(r, role)
    assertEqual(u, user)
