Example #1
0
def test_list_page_per_item(request, setup_a_provider, page, set_list):
    """ Tests list items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.list_view_limit
    navigate_to(page, 'All')
    tb.select('List View')
    if paginator.rec_total() is not None:
        if int(paginator.rec_total()) >= int(limit):
            assert int(paginator.rec_end()) == int(limit), \
                "Listview Failed for page {}!".format(page)
Example #2
0
def test_tile_page_per_item(request, setup_a_provider, page, set_tile):
    """ Tests tile items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.tile_view_limit
    sel.force_navigate(page)
    tb.select('Tile View')
    if paginator.rec_total() is not None:
        if int(paginator.rec_total()) >= int(limit):
            assert int(paginator.rec_end()) == int(limit), \
                "Tileview Failed for page {}!".format(page)
Example #3
0
def _get_tasks(location, **filter_kwargs):
    """ Generic function to return contents of the tasks table

    Args:
        location: Location for :py:module:`ui_navigate` where to get the data.
        **filter_kwargs: See :py:meth:`_filter`
    Returns: List of dicts.
    """
    sel.force_navigate(location)
    if any([filter_kwargs[key] is not None for key in filter_kwargs.keys()]):
        _filter(**filter_kwargs)
    tasks = []

    if sel.is_displayed(tasks_table):
        have_next_page = True
        while have_next_page:
            for row in tasks_table.rows():
                tasks.append(
                    dict(
                        updated=parsetime.from_american_with_utc(row.updated.text.encode("utf-8").strip()),
                        started=parsetime.from_american_with_utc(row.started.text.encode("utf-8").strip()),
                        state=row.state.text.encode("utf-8").strip(),
                        message=row.message.text.encode("utf-8").strip(),
                        task_name=row.task_name.text.encode("utf-8").strip(),
                        user=row.user.text.encode("utf-8").strip(),
                    )
                )
            if int(paginator.rec_end()) < int(paginator.rec_total()):
                sel.click(paginator.next())
            else:
                have_next_page = False
    return tasks
def test_grid_page_per_item(request, setup_a_provider, page, set_grid):
    """ Tests grid items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.grid_view_limit
    # TODO replace with utils.appliance.implementations.ui.navigate_to
    # when all grid_pages support it
    sel.force_navigate(page)
    tb.select('Grid View')
    if paginator.rec_total() is not None:
        if int(paginator.rec_total()) >= int(limit):
            assert int(paginator.rec_end()) == int(limit), \
                "Gridview Failed for page {}!".format(page)
def test_cloud_tile_page_per_item(request, page, set_tile, appliance):
    """ Tests tile items per page

    Metadata:
        test_flag: visuals
    """
    if issubclass(page, BaseCollection):
        page = page(appliance)
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.tile_view_limit
    navigate_to(page, 'All')
    tb.select('Tile View')
    from cfme.web_ui import paginator
    if paginator.rec_total() is not None:
        if int(paginator.rec_total()) >= int(limit):
            assert int(paginator.rec_end()) == int(limit), \
                "Tileview Failed for page {}!".format(page)
def test_report_page_per_item(setup_a_provider, set_report):
    """ Tests report items per page

    Metadata:
        test_flag: visuals
    """
    path = ["Configuration Management", "Virtual Machines", "VMs Snapshot Summary"]
    limit = visual.report_view_limit
    report = CannedSavedReport.new(path)
    report.navigate()
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(limit), "Reportview Failed!"
def test_grid_page_per_item(request, setup_a_provider, page, set_grid):
    """ Tests grid items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.grid_view_limit
    sel.force_navigate(page)
    tb.select("Grid View")
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(limit), "Gridview Failed for page {}!".format(page)
Example #8
0
def clear_infra_providers(validate=True):
    sel.force_navigate('infrastructure_providers')
    logger.debug('Checking for existing infrastructure providers...')
    if paginator.rec_total():
        logger.info(' Providers exist, so removing all infra providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Infrastructure Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_infra_providers()
Example #9
0
def clear_container_providers(validate=True):
    sel.force_navigate("containers_providers")
    logger.debug("Checking for existing container providers...")
    total = paginator.rec_total()
    if total > 0:
        logger.info(" Providers exist, so removing all container providers")
        paginator.results_per_page("100")
        sel.click(paginator.check_all())
        toolbar.select("Configuration", "Remove Containers Providers from the VMDB", invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_container_providers()
def test_list_page_per_item(request, setup_a_provider, page, set_list):
    """ Tests list items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.list_view_limit
    sel.force_navigate(page)
    tb.select('List View')
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(limit), "Listview Failed for page {}!".format(page)
Example #11
0
def clear_middleware_providers(validate=True):
    sel.force_navigate('middleware_providers')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all middleware providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Middleware Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_middleware_providers()
def test_report_page_per_item(setup_a_provider, set_report):
    """ Tests report items per page

    Metadata:
        test_flag: visuals
    """
    path = ["Configuration Management", "Virtual Machines", "VMs Snapshot Summary"]
    limit = visual.report_view_limit
    report = CannedSavedReport.new(path)
    report.navigate()
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(limit), "Reportview Failed!"
Example #13
0
def test_infra_tile_page_per_item(request, page, set_tile):
    """ Tests tile items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.tile_view_limit
    navigate_to(page, 'All')
    tb.select('Tile View')
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(
            limit), "Tileview Failed for page {}!".format(page)
Example #14
0
def clear_infra_providers(validate=True):
    sel.force_navigate('infrastructure_providers')
    logger.debug('Checking for existing infrastructure providers...')
    if paginator.rec_total():
        logger.info(' Providers exist, so removing all infra providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration',
                       'Remove Infrastructure Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_infra_providers()
Example #15
0
def test_infra_list_page_per_item(request, page, set_list):
    """ Tests list items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.list_view_limit
    navigate_to(page, 'All')
    tb.select('List View')
    from cfme.web_ui import paginator
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(limit), "Listview Failed for page {}!".format(page)
Example #16
0
def clear_container_providers(validate=True):
    sel.force_navigate('containers_providers')
    logger.debug('Checking for existing container providers...')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all container providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Containers Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_container_providers()
def test_infra_list_page_per_item(request, page, set_list):
    """ Tests list items per page

    Metadata:
        test_flag: visuals
    """
    request.addfinalizer(lambda: go_to_grid(page))
    limit = visual.list_view_limit
    navigate_to(page, 'All')
    tb.select('List View')
    from cfme.web_ui import paginator
    if int(paginator.rec_total()) >= int(limit):
        assert int(paginator.rec_end()) == int(limit), "Listview Failed for page {}!".format(page)
Example #18
0
def clear_cloud_providers(validate=True):
    sel.force_navigate('clouds_providers')
    logger.debug('Checking for existing cloud providers...')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all cloud providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Cloud Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_cloud_providers()
def get_number_of_vms(do_not_navigate=False):
    """
    Returns the total number of VMs visible to the user,
    including those archived or orphaned
    """
    logger.info("Getting number of vms")
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    if not paginator.page_controls_exist():
        logger.debug("No page controls")
        return 0
    total = paginator.rec_total()
    logger.debug("Number of VMs: %s", total)
    return int(total)
Example #20
0
def get_number_of_vms(do_not_navigate=False):
    """
    Returns the total number of VMs visible to the user,
    including those archived or orphaned
    """
    logger.info("Getting number of vms")
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    if not paginator.page_controls_exist():
        logger.debug("No page controls")
        return 0
    total = paginator.rec_total()
    logger.debug("Number of VMs: {}".format(total))
    return int(total)
def get_number_of_vms(do_not_navigate=False):
    """
    Returns the total number of VMs visible to the user,
    including those archived or orphaned
    """
    logger.info("Getting number of vms")
    if not do_not_navigate:
        navigate_to(Vm, 'VMsOnly')
    if not paginator.page_controls_exist():
        logger.debug("No page controls")
        return 0
    total = paginator.rec_total()
    logger.debug("Number of VMs: %s", total)
    return int(total)
Example #22
0
def clear_provider_by_type(prov_class, validate=True):
    string_name = BaseProvider.type_mapping[prov_class].values()[0].string_name
    navigate = "{}_providers".format(BaseProvider.type_mapping[prov_class].values()[0].page_name)
    sel.force_navigate(navigate)
    logger.debug('Checking for existing {} providers...'.format(prov_class))
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all {} providers'.format(prov_class))
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove {} Providers from the VMDB'.format(string_name),
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_providers_by_type(prov_class)
Example #23
0
def clear_middleware_providers(validate=True):
    sel.force_navigate('middleware_providers')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all middleware providers')
        # TODO: Fix.
        # TEXT: "Items per page" hidden and failed to click paginator items drop down selection
        # For the moment allow it go with default value 20
        # paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Middleware Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_middleware_providers()
Example #24
0
def get_number_of_vms(do_not_navigate=False):
    """
    Returns the total number of VMs visible to the user,
    including those archived or orphaned
    """
    logger.info("Getting number of vms")
    if not do_not_navigate:
        navigate_to(Vm, 'VMsOnly')
    from cfme.web_ui import paginator
    if not paginator.page_controls_exist():
        logger.debug("No page controls")
        return 0
    total = paginator.rec_total()
    logger.debug("Number of VMs: %s", total)
    return int(total)
def test_paginator(some_dialogs, soft_assert, appliance):
    """ This test tests weird behaviour of the paginator in Service dialogs.

    Prerequisities:
        * There have to be couple of service dialogs, about 16 is recommended.

    Steps:
        * Go to service dialogs page
        * Set the paginator to 50 results per page, then to 5 results per page.
        * Assert there are 5 rows displayed in the table
        * Then cycle through the pages. Note all the dialogs you see, in the end the list of all
            dialogs must contain all idalogs you created before.
        * During the cycling, assert the numbers displayed in the paginator make sense
        * During the cycling, assert the paginator does not get stuck.
    """
    navigate_to(DialogCollection(appliance), 'All')
    from cfme.web_ui import paginator
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(
        len(list(dialogs_table.rows())) == 5,
        "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(
                False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(dialogs_table):
            dialogs_found.add(text)

        current_total = paginator.rec_total()
        current_rec_offset = paginator.rec_offset()
        current_rec_end = paginator.rec_end()

        assert current_rec_offset <= current_rec_end <= current_total, \
            "Incorrect paginator value, expected {0} <= {1} <= {2}".format(
                current_rec_offset, current_rec_end, current_total)

    assert {dlg.label for dlg in some_dialogs} <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
Example #26
0
def clear_provider_by_type(prov_class, validate=True):
    string_name = BaseProvider.type_mapping[prov_class].values()[0].string_name
    navigate = "{}_providers".format(
        BaseProvider.type_mapping[prov_class].values()[0].page_name)
    sel.force_navigate(navigate)
    logger.debug('Checking for existing {} providers...'.format(prov_class))
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all {} providers'.format(
            prov_class))
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration',
                       'Remove {} Providers from the VMDB'.format(string_name),
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_providers_by_type(prov_class)
def test_paginator(some_dialogs, soft_assert):
    """ This test tests weird behaviour of the paginator in Service dialogs.

    Prerequisities:
        * There have to be couple of service dialogs, about 16 is recommended.

    Steps:
        * Go to service dialogs page
        * Set the paginator to 50 results per page, then to 5 results per page.
        * Assert there are 5 rows displayed in the table
        * Then cycle through the pages. Note all the dialogs you see, in the end the list of all
            dialogs must contain all idalogs you created before.
        * During the cycling, assert the numbers displayed in the paginator make sense
        * During the cycling, assert the paginator does not get stuck.
    """
    navigate_to(DialogCollection, 'All')
    from cfme.web_ui import paginator
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(len(list(dialogs_table.rows())) == 5, "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(dialogs_table):
            dialogs_found.add(text)

        current_total = paginator.rec_total()
        current_rec_offset = paginator.rec_offset()
        current_rec_end = paginator.rec_end()

        assert current_rec_offset <= current_rec_end <= current_total, \
            "Incorrect paginator value, expected {0} <= {1} <= {2}".format(
                current_rec_offset, current_rec_end, current_total)

    assert {dlg.label for dlg in some_dialogs} <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
Example #28
0
 def clear_provider_by_type(prov_class, validate=True):
     string_name = prov_class.string_name
     navigate_to(prov_class, 'All')
     logger.debug('Checking for existing {} providers...'.format(prov_class.type_tclass))
     total = paginator.rec_total()
     if total > 0:
         logger.info(' Providers exist, so removing all {} providers'.format(
             prov_class.type_tclass))
         paginator.results_per_page('100')
         sel.click(paginator.check_all())
         tb.select(
             'Configuration', {
                 version.LOWEST: 'Remove {} Providers from the VMDB'.format(string_name),
                 '5.7': 'Remove {} Providers'.format(string_name),
             },
             invokes_alert=True)
         sel.handle_alert()
         if validate:
             prov_class.wait_for_no_providers_by_type(prov_class)
Example #29
0
def check_relationships(instance):
    """Check the relationships linking & data integrity"""
    sum_values = instance.summary.relationships.items().values()
    shuffle(sum_values)
    for attr in sum_values:
        if attr.clickable:
            break
    else:
        return  # No clickable object but we still want to pass
    link_value = attr.value
    attr.click()
    if type(link_value) is int:
        rec_total = paginator.rec_total()
        if rec_total != link_value:
            raise Exception('Difference between the value({}) in the relationships table in {}'
                            'to number of records ({}) in the target'
                            'page'.format(link_value, instance.name, rec_total))
    else:
        assert '(Summary)' in summary_title()
def check_relationships(instance):
    """Check the relationships linking & data integrity"""
    instance.summary.reload()  # Because sometimes:
    # AttributeError: 'Summary' object has no attribute 'relationships'
    sum_values = instance.summary.relationships.items().values()
    shuffle(sum_values)
    for attr in sum_values:
        if attr.clickable:
            break
    else:
        return  # No clickable object but we still want to pass
    link_value = attr.value
    attr.click()
    if type(link_value) is int:
        rec_total = paginator.rec_total()
        if rec_total != link_value:
            raise Exception(
                'Difference between the value({}) in the relationships table in {}'
                'to number of records ({}) in the target'
                'page'.format(link_value, instance.name, rec_total))
    else:
        assert '(Summary)' in summary_title()
Example #31
0
def get_paginator_value():
    return paginator.rec_total()
Example #32
0
def get_paginator_value():
    return paginator.rec_total()
Example #33
0
def clear_middleware_providers(validate=True):
    sel.force_navigate('middleware_providers')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all middleware providers')
Example #34
0
def get_paginator_value():
    total = paginator.rec_total()
    if total is None:
        return 0
    else:
        return int(total.strip())
Example #35
0
def wait_for_no_infra_providers():
    sel.force_navigate('infrastructure_providers')
    logger.debug('Waiting for all infra providers to disappear...')
    wait_for(lambda: not paginator.rec_total(), message="Delete all infrastructure providers",
             num_sec=1000, fail_func=sel.refresh)
Example #36
0
def get_paginator_value():
    total = paginator.rec_total()
    if total is None:
        return 0
    else:
        return int(total.strip())