'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_get_user_id('admin@example.com')
    current.db((table.id == record_id)).update(owned_by_user=user_id, owned_by_group=sr.AUTHENTICATED)
    s3_impersonate('admin@example.com')
    assertTrue(is_owner(table, record_id))
    s3_impersonate('normaluser@example.com')
    assertTrue(is_owner(table, record_id))
    s3_impersonate(None)
    assertFalse(is_owner(table, record_id))
    auth.s3_make_session_owner(table, record_id)
    assertTrue(is_owner(table, record_id))
