Example #1
0
def get_role(nav, name):

    log_this(__name__, inspect.stack()[0][3], '(start)', name)
    nav.confirm_home()

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].user_roles().click()

    # select from the list
    list_view = nav.dialog['user_roles'].user_roles_list()
    [found, control] = find_and_select(name, list_view)

    the_results = {}
    privs_get = {}
    if found:
        the_results = {}
        the_results['role'] = name

        # get list of controls for the privs buttons
        controls = nav.dialog['user_roles'].get_privs_controls()

        for name, control in controls.items():
            the_control_value = control.get_toggle_state()
            privs_get[name] = the_control_value

        the_results['privs_get'] = privs_get

    # go home
    nav.dialog['user_roles'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return the_results
Example #2
0
def cancel_test_by_serial_number_or_lims_id(
    nav, by, number_or_id):

    log_this(__name__, inspect.stack()[0][3], '(start)')
    dlg_app = nav.confirm_home()

    # transition UI
    nav.dialog['home'].retrieve().click()

    list_view = nav.dialog['retrieve'].test_list()

    for data_item in list_view.items():
        result = __get_data_from_row(data_item)

        if (
            (by == "serial_number" and (result.get('serial_number') == number_or_id))
            or
            (by == "lims_id" and (result.get('lims_id') == number_or_id))
        ):

            data_item.select()
            # data_item.click()

            try:
                nav.dialog['retrieve'].cancel().click()
            except Exception as e:
                print('Oops! when trying to cancel by {} {}'.format(by, number_or_id))
                print('got a ', e.__class__)
                print('are trying to cancel a test that is already complete?')

            break

    # go home
    nav.dialog['retrieve'].home().click()
    log_this(__name__, inspect.stack()[0][3], '(end)')
Example #3
0
def delete_role(nav, params_encoded):

    log_this(__name__, inspect.stack()[0][3], '(start)', params_encoded)
    nav.confirm_home()

    try:
        params_decoded = json.loads(params_encoded)
        name = params_decoded['name']
    except Exception as e:
        this_err = 'when deleting role, missing role name - was given {}'.format(
            params_encoded)
        raise RuntimeError(this_err) from e

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].user_roles().click()

    list_view = nav.dialog['user_roles'].user_roles_list()

    # select from the list
    [found, control] = find_and_select(name, list_view)

    if found:
        nav.dialog['user_roles'].delete().click()

    # go home
    nav.dialog['user_roles'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return
Example #4
0
def enable_user(nav, params_encoded):

    log_this(__name__, inspect.stack()[0][3], '(start)')
    nav.confirm_home()

    try:
        params_decoded = json.loads(params_encoded)
        username = params_decoded['username']
    except Exception as e:
        this_err = 'missing one or more parameters - was given {}'.format(
            params_encoded)
        raise RuntimeError(this_err) from e

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].users().click()

    # pick user from "Users" list
    list_view = nav.dialog['users'].users_list()

    # select from the list
    [found, control] = find_and_select(username, list_view)

    if found:
        nav.dialog['users'].enable().click()

    # go home
    nav.dialog['users'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return
Example #5
0
def update_role(nav, params_encoded):

    log_this(__name__, inspect.stack()[0][3], '(start)', params_encoded)
    nav.confirm_home()

    try:
        params_decoded = json.loads(params_encoded)
        name = params_decoded['name']
        privs_set = params_decoded['privs_set']
    except Exception as e:
        this_err = 'missing one or more parameters - was given {}'.format(
            params_encoded)
        raise RuntimeError(this_err) from e

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].user_roles().click()

    list_view = nav.dialog['user_roles'].user_roles_list()

    # select from the list
    [found, control] = find_and_select(name, list_view)

    if found:
        nav.dialog['user_roles'].edit().click()

        # get list of controls for the privs buttons
        controls = nav.dialog['user_roles'].get_privs_controls()

        # set the priv switches
        change_made = False

        for k, v in privs_set.items():
            # Button has 3 possible states 0,1, 2 where "2" means indeterminant...
            # so it may be necessary to toggle twice to get to the desired state
            for x in range(0, 2):
                try:
                    the_control = controls[k]
                    the_control_value = the_control.get_toggle_state()
                    if str(the_control_value) != str(v):
                        the_control.toggle()
                        change_made = True
                except KeyError as e:
                    this_err = 'attempt to set role priv {} which does not exist in list {}'.format(
                        k, controls.keys())
                    raise KeyError(this_err) from e

        if change_made:
            nav.dialog['user_roles'].save().click()
        else:
            nav.dialog['user_roles'].cancel().click()

    nav.dialog['user_roles'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return
Example #6
0
def left_load(nav):

    log_this(__name__, inspect.stack()[0][3], '(start)')
    dlg_app = nav.confirm_home()

    nav.dialog['home'].left_load().click()
    y = ''

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return y
Example #7
0
def get_test_list(nav):
    
    log_this(__name__, inspect.stack()[0][3], '(start)')
    dlg_app = nav.confirm_home()

    # transition UI
    nav.dialog['home'].retrieve().click()

    list_view = nav.dialog['retrieve'].test_list()

    y = __get_data_from_table(list_view)

    # go home
    nav.dialog['retrieve'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return y  
Example #8
0
def get_list(nav, verbose=False):

    log_this(__name__, inspect.stack()[0][3], '(start)')
    nav.confirm_home()

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].user_roles().click()

    list_view = nav.dialog['user_roles'].user_roles_list()

    columns = ['name']
    key = 'name'
    df_accumulate = pd.DataFrame([], columns=columns)
    for x in list_view:
        if verbose:
            print(x.texts())
        current_display_df = pd.DataFrame([x.texts()], columns=columns)
        df_accumulate = df_accumulate.append(current_display_df,
                                             ignore_index=False,
                                             verify_integrity=False,
                                             sort=False)
    df_rationalized = df_accumulate.drop_duplicates(subset=key,
                                                    keep='last',
                                                    inplace=False,
                                                    ignore_index=False)
    df_indexed_by_name = df_rationalized.set_index(keys=key,
                                                   drop=True,
                                                   append=False,
                                                   inplace=False,
                                                   verify_integrity=True)
    # df_indexed_by_name.sort_index(inplace=True)

    # the_results = df_indexed_by_name.to_dict(orient='dict')
    # the_results = df_indexed_by_name.to_dict(orient='list')
    # the_results = df_indexed_by_name.to_dict(orient='series')
    # the_results = df_indexed_by_name.to_dict(orient='split')
    # the_results = df_indexed_by_name.to_dict(orient='records')
    the_results = df_indexed_by_name.to_dict(orient='index')

    # go home
    nav.dialog['user_roles'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return the_results
Example #9
0
def get_test_list(nav):

    log_this(__name__, inspect.stack()[0][3], '(start)')
    dlg_app = nav.confirm_home()

    list_view = nav.dialog['home'].test_list()

    try:
        y = __get_data_from_table(list_view)
    except Exception as e:
        print('FAIL--> with: ' + str(e.__class__))
        print('-------- will wait, retry------')
        time.sleep(3)
        y = __get_data_from_table(list_view)
        print('-------- retry sucessful ------')

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return y
Example #10
0
def get_user(nav, name):

    log_this(__name__, inspect.stack()[0][3], '(start)', name)
    nav.confirm_home()

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].users().click()

    list_view = nav.dialog['users'].users_list()

    # select from the list
    [found, control] = find_and_select(name, list_view)

    the_results = {}
    if found:
        the_results['first'] = nav.dialog['users'].first().texts()[0]
        the_results['middle'] = nav.dialog['users'].middle().texts()[0]
        the_results['last'] = nav.dialog['users'].last().texts()[0]
        the_results['username'] = nav.dialog['users'].username().texts()[0]
        the_results['email'] = nav.dialog['users'].email().texts()[0]
        # the_results['password_a'] = nav.dialog['users'].password_a().texts()[0]
        the_results['phone'] = nav.dialog['users'].phone().texts()[0]
        # the_results['password_b'] = nav.dialog['users'].password_b().texts()[0]
        the_results['extension'] = nav.dialog['users'].extension().texts()[0]

        # the_results['role']  = nav.dialog['users'].user_role().texts()[0]
        the_results['role'] = 'not implemented'

        privs_get = {}
        # get list of controls for the privs buttons
        controls = nav.dialog['users'].get_privs_controls()

        for name, control in controls.items():
            the_control_value = control.get_toggle_state()
            privs_get[name] = the_control_value

        the_results['privs_get'] = privs_get

    # go home
    nav.dialog['users'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return the_results
Example #11
0
def update_user(nav, params_encoded):

    log_this(__name__, inspect.stack()[0][3], '(start)')
    nav.confirm_home()

    try:
        params_decoded = json.loads(params_encoded)
        first = params_decoded['first']
        middle = params_decoded['middle']
        last = params_decoded['last']
        username = params_decoded['username']
        email = params_decoded['email']
        password = params_decoded['password']
        phone = params_decoded['phone']
        extension = params_decoded['extension']
        role = params_decoded['role_name']
    except Exception as e:
        this_err = 'missing one or more parameters - was given {}'.format(
            params_encoded)
        raise RuntimeError(this_err) from e

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].users().click()

    # pick user from "Users" list
    list_view = nav.dialog['users'].users_list()

    # select from the list
    [found, control] = find_and_select(username, list_view)

    if (found):
        nav.dialog['users'].edit().click()

        nav.dialog['users'].first().set_text(first)
        nav.dialog['users'].middle().set_text(middle)
        nav.dialog['users'].last().set_text(last)
        # nav.dialog['users'].username().set_text(username) not enabled - makes sense
        nav.dialog['users'].email().set_text(email)
        nav.dialog['users'].password_a().set_text(password)
        nav.dialog['users'].phone().set_text(phone)
        nav.dialog['users'].extension().set_text(extension)
        nav.dialog['users'].password_b().set_text(password)

        # dropdown
        the_combo_box = nav.dialog['users'].role_combo_box()
        the_combo_box.type_keys("%{DOWN}")

        x = the_combo_box.children()
        num = -1
        for y in x:
            num += 1
            y.click_input()
            # print("========")
            # print("texts {}".format(y.texts()))
            # print("window_text {}".format(y.window_text()))
            # print("element info {}".format(y.element_info))
            # z = y.get_properties()
            if (y.texts()[0] == role):
                the_combo_box.select(num)
                break

        nav.dialog['users'].save().click()

    # go home
    nav.dialog['users'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return
Example #12
0
def create_user(nav, params_encoded):

    log_this(__name__, inspect.stack()[0][3], '(start)', params_encoded)
    nav.confirm_home()

    try:
        params_decoded = json.loads(params_encoded)
        first = params_decoded['first']
        middle = params_decoded['middle']
        last = params_decoded['last']
        username = params_decoded['username']
        email = params_decoded['email']
        password = params_decoded['password']
        phone = params_decoded['phone']
        extension = params_decoded['extension']
        role = params_decoded['role_name']
    except Exception as e:
        this_err = 'missing one or more parameters - was given {}'.format(
            params_encoded)
        raise RuntimeError(this_err) from e

    # transition UI
    nav.dialog['home'].menu().click()
    nav.dialog['menu'].users().click()

    nav.dialog['users'].new().click()

    nav.dialog['users'].first().type_keys(first)
    nav.dialog['users'].middle().type_keys(middle)
    nav.dialog['users'].last().type_keys(last)
    nav.dialog['users'].username().type_keys(username)
    nav.dialog['users'].email().type_keys(email)
    nav.dialog['users'].password_a().type_keys(password)
    nav.dialog['users'].phone().type_keys(phone)
    nav.dialog['users'].extension().type_keys(extension)
    nav.dialog['users'].password_b().type_keys(password)

    # dropdown for role
    the_combo_box = nav.dialog['users'].role_combo_box()
    # dlg_app =   nav.dialog['users'].app.window(title=r'GrowthDirect2', top_level_only=True)
    # the_combo_box = dlg_app.child_window(auto_id="cmb_UserRoles", control_type="ComboBox")
    the_combo_box.type_keys("%{DOWN}")

    x = the_combo_box.children()
    num = -1
    for y in x:
        num += 1
        y.click_input()
        # print("========")
        # print("texts {}".format(y.texts()))
        # print("window_text {}".format(y.window_text()))
        # print("element info {}".format(y.element_info))
        # z = y.get_properties()
        if (y.texts()[0] == role):
            #print('{} {}'.format(num, role))
            the_combo_box.select(num)
            break

    nav.dialog['users'].save().click()

    # go home
    nav.dialog['users'].home().click()

    log_this(__name__, inspect.stack()[0][3], '(end)')
    return