Exemplo n.º 1
0
def test_custom_dashboards(request, soft_assert, number_dashboards):
    """Create some custom dashboards and check their presence. Then check their contents."""
    # Very useful construct. List is mutable, so we can prepare the generic delete finalizer.
    # Then we add everything that succeeded with creation. Simple as that :)
    dashboards = []
    request.addfinalizer(lambda: map(lambda item: item.delete(), dashboards))

    def _create_dashboard(widgets):
        return Dashboard(
            fauxfactory.gen_alphanumeric(),
            "EvmGroup-super_administrator",
            fauxfactory.gen_alphanumeric(),
            locked=False,
            widgets=widgets
        )

    for i in range(number_dashboards):
        d = _create_dashboard(sample(AVAILABLE_WIDGETS, 3))
        d.create()
        dashboards.append(d)
    dash_dict = {d.title: d for d in dashboards}
    try:
        for dash_name in dashboard.dashboards():
            soft_assert(dash_name in dash_dict, "Dashboard {} not found!".format(dash_name))
            if dash_name in dash_dict:
                for widget in Widget.all():
                    soft_assert(widget.name in dash_dict[dash_name].widgets,
                                "Widget {} not found in {}!".format(widget.name, dash_name))
                del dash_dict[dash_name]
        soft_assert(not dash_dict, "Some of the dashboards were not found! ({})".format(
            ", ".join(dash_dict.keys())))
    except IndexError:
        pytest.fail("No dashboard selection tabs present on dashboard!")
Exemplo n.º 2
0
def test_custom_dashboards(request, soft_assert, number_dashboards):
    """Create some custom dashboards and check their presence. Then check their contents."""
    # Very useful construct. List is mutable, so we can prepare the generic delete finalizer.
    # Then we add everything that succeeded with creation. Simple as that :)
    dashboards = []
    request.addfinalizer(lambda: map(lambda item: item.delete(), dashboards))

    def _create_dashboard(widgets):
        return Dashboard(fauxfactory.gen_alphanumeric(),
                         "EvmGroup-super_administrator",
                         fauxfactory.gen_alphanumeric(),
                         locked=False,
                         widgets=widgets)

    for i in range(number_dashboards):
        d = _create_dashboard(sample(AVAILABLE_WIDGETS, 3))
        d.create()
        dashboards.append(d)
    dash_dict = {d.title: d for d in dashboards}
    try:
        for dash_name in dashboard.dashboards():
            soft_assert(dash_name in dash_dict,
                        "Dashboard {} not found!".format(dash_name))
            if dash_name in dash_dict:
                for widget in Widget.all():
                    soft_assert(
                        widget.name in dash_dict[dash_name].widgets,
                        "Widget {} not found in {}!".format(
                            widget.name, dash_name))
                del dash_dict[dash_name]
        soft_assert(
            not dash_dict,
            "Some of the dashboards were not found! ({})".format(", ".join(
                dash_dict.keys())))
    except IndexError:
        pytest.fail("No dashboard selection tabs present on dashboard!")