예제 #1
0
def _verify_resource_deleted(resource):
    logger.info("Verify Deleting the resource %s from scope" % resource.name)
    EditScopes.click_edit_scope_button()
    EditScopes.click_remove_resources_button()
    EditScopes.input_and_select_remove_resource_category(resource.category)
    VerifyScopes.verify_resource_deleted(resource)
    return True
예제 #2
0
def select_scope(scope_name):
    """ Select Scope  """
    logger.info("Selecting scope %s :" % scope_name)
    navigate()
    CommonOperationScopes.select_scope(scope_name)
    VerifyScopes.verify_scope_created(scope_name)
    return True
예제 #3
0
def validate_user_privilege():
    """ validate user  """
    logger.info("navigating scope")
    navigate()

    if VerifyScopes.verify_create_scope_button_not_exist(fail_if_false=False) is True:
        logger.info("user has no privilege to create scope")
        VerifyScopes.verify_user_authorizaton(fail_if_false=False)
        return True
    else:
        return FusionUIBase.fail_test_or_return_false("Unexpected behaviour")
예제 #4
0
def delete_scope(*scopes_obj):
    """ Delete Scope

        Example:
        | `Delete Scope`      | ${myScopeList}    |
    """
    logger.info("Delete Scope")
    navigate()
    if isinstance(scopes_obj, test_data.DataObj):
        scopes_obj = [scopes_obj]
    elif isinstance(scopes_obj, tuple):
        scopes_obj = list(scopes_obj[0])

    total = len(scopes_obj)
    not_exists = 0
    deleted = 0

    for n, scope in enumerate(scopes_obj):
        logger.info("{2} No: {0} --- Total: {1} {2}".format((n + 1), total, '-' * 14))
        logger.info("deleting a scope named '%s'" % scope.name)
        if VerifyScopes.verify_scope_existed(scope.name, 5, False) is True:
            select_scope(scope.name)
            DeleteScopes.click_delete_scope_button()
            DeleteScopes.click_yes_delete_button()
            DeleteScopes.wait_delete_scope_dialog_close()
            FusionUIBase.show_activity_sidebar()
            if not FusionUIBase.wait_activity_action_ok(scope.name, 'Delete', timeout=60, fail_if_false=False):
                FusionUIBase.show_activity_sidebar()
                continue
            FusionUIBase.show_activity_sidebar()
            VerifyScopes.verify_scope_not_existed(scope.name)
            deleted += 1
        else:
            logger.warn("scope '%s' does NOT exist! ..." % scope.name)
            not_exists += 1
            continue

    logger.info("{0} == Summary == {0}".format('-' * 14))
    if total - not_exists == 0:
        logger.warn("no scope to delete! all %s scope(s) is NOT existing, keyword '%s' returns a 'False'" % (not_exists, sys._getframe().f_code.co_name))
        return False
    else:
        if deleted < total:
            logger.warn("not all of the scope(s) is successfully deleted - %s out of %s deleted " % (deleted, total))
            if deleted + not_exists == total:
                logger.warn("%s not-existing scope(s) is skipped, keyword '%s' returns a 'False'" % (not_exists, sys._getframe().f_code.co_name))
                return False
            else:
                ui_lib.fail_test("%s not-existing scope(s) is skipped, %s scope(s) left is failed being deleted " % (not_exists, total - deleted - not_exists))

    logger.info("all of the scope(s) is successfully deleted - %s out of %s " % (deleted, total))
    return True
예제 #5
0
def create_scope(*scopes_obj):
    """ Create Scope
        Example:
        | `Create Scope`      | ${myScopeList}    |
    """

    logger.info("Create Scope")
    navigate()
    if isinstance(scopes_obj, test_data.DataObj):
        scopes_obj = [scopes_obj]
    elif isinstance(scopes_obj, tuple):
        scopes_obj = list(scopes_obj[0])

    fail_if_exist = 0

    for scope in scopes_obj:
        if VerifyScopes.verify_scope_existed(scope.name, 5, False):
            fail_if_exist += 1
            logger.warn("scope %s already exists" % scope.name)
            continue
        have_resource = False
        CreateScopes.click_create_scope_button()
        logger.info("Creating scope %s" % scope.name)
        CreateScopes.wait_create_scope_dialog_open()
        CreateScopes.input_name(scope.name)
        if hasattr(scope, 'description'):
            CreateScopes.input_description(scope.description)
        if hasattr(scope, 'resources'):
            for n, resource in enumerate(scope.resources):
                have_resource = True
                _Add_Resource_To_Scope_Add(resource)
        CreateScopes.click_create_plus_button()
        VerifyScopes.verify_create_plus_complete()
        CreateScopes.click_cancel_button()
        CreateScopes.wait_create_scope_dialog_close()

        FusionUIBase.show_activity_sidebar()
        FusionUIBase.wait_activity_action_ok(scope.name, 'Create', timeout=60, fail_if_false=True)
        if have_resource:
            FusionUIBase.wait_activity_action_ok(scope.name, 'Update Resource Assignments', timeout=60, fail_if_false=True)
        FusionUIBase.show_activity_sidebar()

        CommonOperationScopes.select_scope(scope.name)
        VerifyScopes.verify_scope_created(scope.name)

    if fail_if_exist > 0:
        return False
    return True
예제 #6
0
def assign_scope_bulk_networks(*scope_obj):
    """ Edit Scope    """
    logger.info("Edit Scope")
    navigate()
    if isinstance(scope_obj, test_data.DataObj):
        scope_obj = [scope_obj]
    elif isinstance(scope_obj, tuple):
        scope_obj = list(scope_obj[0])
    fail_if_exist = 0
    #    Looping to edit all the resources present in the resources.txt file
    for scope in scope_obj:
        logger.info("Editing scope %s" % scope.name)
        if scope.has_property("new_name"):
            if scope.new_name != scope.name and VerifyScopes.verify_scope_existed(scope.new_name, 5, False):
                fail_if_exist += 1
                logger.warn("scope %s already exists, can't edit scope" % scope.new_name)
                continue

        #    Selecting the given scope
        if CommonOperationScopes.select_scope(scope.name):
            #    Clicking on edit button and verifying the edit options page
            CommonOperationScopes.wait_for_scopes_load()
            EditScopes.click_edit_scope_button()
            EditScopes.wait_edit_scope_dialog_open()
            EditScopes.click_add_resources_button()
            EditScopes.wait_add_resources_dialog_open()
            EditScopes.input_and_select_resource_category(scope.category)
            CommonOperationScopes.load_bulk_enets()
            EditScopes.click_add_button()
            EditScopes.wait_add_resources_dialog_close()
            EditScopes.click_ok_button()
            EditScopes.wait_edit_scope_dialog_close()
    if fail_if_exist > 0:
        return FusionUIBase.fail_test_or_return_false("Failed to assign bulk resource")
    return True
예제 #7
0
def delete_all_scopes():
    """ Remove All Scopes    """
    logger.info("Remove All Scopes")
    navigate()
    #    get the list of scopes
    if not CommonOperationScopes.wait_for_scopes_load():
        logger.info("There is no scopes")
        return True
    scopes = CommonOperationScopes.get_scope_list()
    for scope in scopes:
        if VerifyScopes.verify_scope_existed(scope, 5, False) is True:
            select_scope(scope)
            DeleteScopes.click_delete_scope_button()
            DeleteScopes.click_yes_delete_button()
            DeleteScopes.wait_delete_scope_dialog_close()
            #    VerifyScopes.verify_scope_deleted(scope)
            VerifyScopes.verify_scope_not_existed(scope)
    return True
예제 #8
0
def edit_scope(*scope_obj):
    """ Edit Scope    """
    logger.info("Edit Scope")
    navigate()
    if isinstance(scope_obj, test_data.DataObj):
        scope_obj = [scope_obj]
    elif isinstance(scope_obj, tuple):
        scope_obj = list(scope_obj[0])
    fail_if_exist = 0
    #    Looping to edit all the resources present in the resources.txt file
    for scope in scope_obj:
        logger.info("Editing scope %s" % scope.name)
        if scope.has_property("new_name"):
            if scope.new_name != scope.name and VerifyScopes.verify_scope_existed(scope.new_name, 5, False):
                fail_if_exist += 1
                logger.warn("scope %s already exists, can't edit scope" % scope.new_name)
                continue

        have_resource = False
        #    Selecting the given scope
        if CommonOperationScopes.select_scope(scope.name):
            #    Clicking on edit button and verifying the edit options page
            CommonOperationScopes.wait_for_scopes_load()
            EditScopes.click_edit_scope_button()
            EditScopes.wait_edit_scope_dialog_open()
            if scope.has_property("new_name"):
                data = _Verify_Parameter(scope.new_name, "Scope Name")
                if not (data == "none" or data == ""):
                    EditScopes.input_name(data)
            #    deleting resources
            if hasattr(scope, 'remove_resources'):
                for n, resource in enumerate(scope.remove_resources):
                    have_resource = True
                    logger.info("Deleting resource %s from scope" % resource.name)
                    #   EditScopes.remove_resources_by_name(resource.name)
                    EditScopes.click_remove_resources_button()
                    EditScopes.input_and_select_remove_resource_category(resource.category)
                    EditScopes.click_remove_resources_button_from_scope()
                    #   EditScopes.click_ok_button()
                    #   VerifyScopes.verify_resource_deleted(resource.name)
            #    add resources
            if hasattr(scope, 'add_resources'):
                for n, resource in enumerate(scope.add_resources):
                    have_resource = _Add_Resource_To_Scope(resource) or have_resource
            EditScopes.click_ok_button()
            EditScopes.wait_edit_scope_dialog_close()

        if have_resource:
            FusionUIBase.show_activity_sidebar()
            FusionUIBase.wait_activity_action_ok(scope.name, 'Update', timeout=120, fail_if_false=True)
            FusionUIBase.show_activity_sidebar()

    if fail_if_exist > 0:
        return False
    return True
예제 #9
0
def _Add_Resource_To_Scope_Add(resource):
    """_Add_Resource_To_Scope_Add
      Add resource to scope while creating the scope.
        Example:
        | _Add_Resource_To_Scope_Add(Resource)"""

    if VerifyScopes.verify_add_resource_existed(resource.name):
        logger.info("Resource %s is already added to the given scope" % resource.name)
        return True
    else:
        CreateScopes.click_add_resources_button()
        CreateScopes.wait_add_resources_dialog_open()
        CreateScopes.input_and_select_resource_category(resource.category)
        CreateScopes.input_resource_name(resource.name)
        CreateScopes.click_resource_name(resource.name)
        CreateScopes.click_add_button()
        CreateScopes.wait_add_resources_dialog_close()
    return True
예제 #10
0
def edit_verify_scope(*scope_obj):
    """ Edit Scope    """
    logger.info("Edit and Verify Scope")
    navigate()
    if isinstance(scope_obj, test_data.DataObj):
        scope_obj = [scope_obj]
    elif isinstance(scope_obj, tuple):
        scope_obj = list(scope_obj[0])
    fail_if_exist = 0
    #    Looping to edit all the resources present in the resources.txt file
    for scope in scope_obj:
        logger.info("Editing scope %s" % scope.name)
        if scope.has_property("new_name"):
            if scope.new_name != scope.name and VerifyScopes.verify_scope_existed(scope.new_name, 5, False):
                fail_if_exist += 1
                logger.warn("scope %s already exists, can't edit scope" % scope.new_name)
                continue
        #    Selecting the given scope
        if CommonOperationScopes.select_scope(scope.name):
            #    Clicking on edit button and verifying the edit options page
            CommonOperationScopes.wait_for_scopes_load()
            EditScopes.click_edit_scope_button()
            EditScopes.wait_edit_scope_dialog_open()
            if scope.has_property("new_name"):
                data = _Verify_Parameter(scope.new_name, "Scope Name")
                if not (data == "none" or data == ""):
                    EditScopes.input_name(data)
    EditScopes.click_ok_button()

    validate_msg = CommonOperationScopes.get_scopename_validate_message()
    EditScopes.click_cancel_button()
    EditScopes.wait_edit_scope_dialog_close()
    if validate_msg is None and fail_if_exist == 0:
        FusionUIBase.fail_test_or_return_false("Failed to find the required element")
    else:
        return validate_msg