def test_revokePrivilegeForPerson_Person_JSON(self):
        # Sub-Test 1: Invalid person key.
        # Define prerequisite data.
        privilegeKey = 7
        personKey = 9999
        organizationKey = 1
        # Get the result of the tested method.
        result = controller_privileges.revokePrivilegeForPersonJSON(self.db, privilegeKey, personKey, organizationKey)
        # Validate the result.
        self.assertEqual(result, '{"success":"false"}')

        # Sub-Test 2: Invalid privilege key.
        # Define prerequisite data.
        privilegeKey = 9999
        personKey = 4
        organizationKey = 1
        # Get the result of the tested method.
        result = controller_privileges.revokePrivilegeForPersonJSON(self.db, privilegeKey, personKey, organizationKey)
        # Validate the result.
        self.assertEqual(result, '{"success":"false"}')

        # Sub-Test 3: Invalid organization key.
        # Define prerequisite data.
        privilegeKey = 7
        personKey = 4
        organizationKey = 9999
        # Get the result of the tested method.
        result = controller_privileges.revokePrivilegeForPersonJSON(self.db, privilegeKey, personKey, organizationKey)
        # Validate the result.
        self.assertEqual(result, '{"success":"false"}')

        # Sub-Test 4: Valid execution.
        # Define prerequisite data.
        privilegeKey = 8
        personKey = 4
        organizationKey = 1
        # Get the result of the tested method.
        result = controller_privileges.revokePrivilegeForPersonJSON(self.db, privilegeKey, personKey, organizationKey)
        # Validate the result.
        self.assertEqual(result, '{"success":"true"}')

        # Sub-Test 5: Duplicate permission.
        # Define prerequisite data.
        privilegeKey = 8
        personKey = 4
        organizationKey = 1
        # Get the result of the tested method.
        result = controller_privileges.revokePrivilegeForPersonJSON(self.db, privilegeKey, personKey, organizationKey)
        # Validate the result.
        self.assertEqual(result, '{"success":"true"}')
Exemplo n.º 2
0
def privilege_org_member_remove_privilege(org_id, person_id, privilege_id):
    try:
        user_id = current_user.entityFK;

        if request.method == 'DELETE':

            if is_request_json():
                result = controller_privileges.revokePrivilegeForPersonJSON(db, privilege_id, person_id, org_id)
                return Response(response=result, mimetype='application/json')

    except Exception, e:
        return abort(404)