示例#1
0
def test_widgets_on_dashboard(request, dashboard, default_widgets, custom_widgets, soft_assert):
    with update(dashboard):
        dashboard.widgets = map(lambda w: w.title, custom_widgets)

    def _finalize():
        with update(dashboard):
            dashboard.widgets = default_widgets
    request.addfinalizer(_finalize)
    dashboard.reset_widgets()
    soft_assert(len(Widget.all()) == len(custom_widgets), "Count of the widgets differ")
    for custom_w in custom_widgets:
        try:
            Widget.by_name(custom_w.title)
        except NameError:
            soft_assert(False, "Widget {} not found on dashboard".format(custom_w.title))
示例#2
0
def test_widgets_on_dashboard(request, dashboard, default_widgets, custom_widgets, soft_assert):
    with update(dashboard):
        dashboard.widgets = map(lambda w: w.title, custom_widgets)

    def _finalize():
        with update(dashboard):
            dashboard.widgets = default_widgets
    request.addfinalizer(_finalize)
    view = navigate_to(Server, "Dashboard")
    view.reset_widgets()
    soft_assert(len(Widget.all()) == len(custom_widgets), "Count of the widgets differ")
    for custom_w in custom_widgets:
        try:
            Widget.by_name(custom_w.title)
        except NameError:
            soft_assert(False, "Widget {} not found on dashboard".format(custom_w.title))
示例#3
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!")
示例#4
0
def test_widgets_on_dashboard(request, dashboard, default_widgets, custom_widgets, soft_assert):
    with update(dashboard):
        dashboard.widgets = map(lambda w: w.title, custom_widgets)

    def _finalize():
        with update(dashboard):
            dashboard.widgets = default_widgets
    request.addfinalizer(_finalize)
    sel.force_navigate("dashboard")
    toolbar.select("Reset Dashboard Widgets to the defaults", invokes_alert=True)
    sel.handle_alert(False)
    soft_assert(len(Widget.all()) == len(custom_widgets), "Count of the widgets differ")
    for custom_w in custom_widgets:
        try:
            Widget.by_name(custom_w.title)
        except NameError:
            soft_assert(False, "Widget {} not found on dashboard".format(custom_w.title))
示例#5
0
def test_verify_rss_links(widgets_generated):
    pytest.sel.force_navigate("dashboard")
    for widget in Widget.by_type("rss_widget"):
        for desc, date, url in widget.content.data:
            assert url is not None, "Widget {}, line {} - no URL!".format(
                repr(widget.name), repr(desc))
            req = requests.get(url, verify=False)
            assert 200 <= req.status_code < 400, "The url {} seems malformed".format(repr(url))
示例#6
0
def widgets_generated(any_provider_session):
    pytest.sel.force_navigate("dashboard")
    widget_list = []
    for widget in Widget.all():
        widget_list.append((widget.name, widget.content_type))
    for w_name, w_type in widget_list:
        w = widgets.Widget.detect(w_type, w_name)
        w.generate()
示例#7
0
def widgets():
    all_widgets = Widget.all()
    Widgets = namedtuple('Widgets', ('all_widgets', 'all_widgets_ids'))
    yield Widgets(
        all_widgets=all_widgets,
        all_widgets_ids=[widget._div_id for widget in all_widgets]
    )
    DefaultDashboard.reset_widgets()
示例#8
0
def widgets_generated(any_provider_session):
    pytest.sel.force_navigate("dashboard")
    widget_list = []
    for widget in Widget.all():
        widget_list.append((widget.name, widget.content_type))
    for w_name, w_type in widget_list:
        w = widgets.Widget.detect(w_type, w_name)
        wait_for(w.check_status, fail_condition=WAIT_STATES, delay=5, num_sec=180)
        w.generate()
示例#9
0
def widgets_generated(setup_only_one_provider):
    navigate_to(Server, 'Dashboard')
    widget_list = []
    for widget in Widget.all():
        widget_list.append((widget.name, widget.content_type))
    for w_name, w_type in widget_list:
        w = widgets.Widget.detect(w_type, w_name)
        if w.check_status() in w.WAIT_STATES:
            w.wait_generated(timeout=15 * 60)
        else:
            w.generate(timeout=15 * 60)
示例#10
0
def widgets_generated(any_provider_session):
    pytest.sel.force_navigate("dashboard")
    widget_list = []
    for widget in Widget.all():
        widget_list.append((widget.name, widget.content_type))
    for w_name, w_type in widget_list:
        w = widgets.Widget.detect(w_type, w_name)
        if w.check_status() in w.WAIT_STATES:
            w.wait_generated(timeout=15 * 60)
        else:
            w.generate(timeout=15 * 60)
示例#11
0
def widgets_generated(setup_only_one_provider):
    navigate_to(Server, 'Dashboard')
    widget_list = []
    for widget in Widget.all():
        widget_list.append((widget.name, widget.content_type))
    for w_name, w_type in widget_list:
        w = widgets.Widget.detect(w_type, w_name)
        if w.check_status() in w.WAIT_STATES:
            w.wait_generated(timeout=15 * 60)
        else:
            w.generate(timeout=15 * 60)
def test_verify_rss_links(widgets_generated):
    """This test verifies that RSS links on dashboard are working.

    Prerequisities:
        * Generated widgets, at least one RSS.

    Steps:
        * Loop through all RSS widgets
        * Loop through all the links in a widget
        * Try making a request on the provided URLs, should make sense
    """
    navigate_to(Dashboard, "All")
    for widget in Widget.by_type("rss_widget"):
        for desc, date, url in widget.content.data:
            assert url is not None, "Widget {}, line {} - no URL!".format(repr(widget.name), repr(desc))
            req = requests.get(url, verify=False)
            assert 200 <= req.status_code < 400, "The url {} seems malformed".format(repr(url))
示例#13
0
def test_widgets_operation(request):
    navigate_to(Server, 'Dashboard')
    request.addfinalizer(lambda: Widget.close_zoom())
    for widget in Widget.all():
        widget.minimize()
        assert widget.is_minimized
        widget.restore()
        assert not widget.is_minimized
        if widget.can_zoom:
            widget.zoom()
            assert Widget.is_zoomed()
            assert Widget.get_zoomed_name() in widget.name
            Widget.close_zoom()
            assert not Widget.is_zoomed()
        widget.footer
        widget.content
示例#14
0
def test_widgets_operation(request):
    sel.force_navigate("dashboard")
    request.addfinalizer(lambda: Widget.close_zoom())
    for widget in Widget.all():
        widget.minimize()
        assert widget.is_minimized
        widget.restore()
        assert not widget.is_minimized
        if widget.can_zoom:
            widget.zoom()
            assert Widget.is_zoomed()
            assert widget.name == Widget.get_zoomed_name()
            Widget.close_zoom()
            assert not Widget.is_zoomed()
        widget.footer
        widget.content
示例#15
0
def test_widgets_operation(request):
    navigate_to(Server, 'Dashboard')
    request.addfinalizer(lambda: Widget.close_zoom())
    for widget in Widget.all():
        widget.minimize()
        assert widget.is_minimized
        widget.restore()
        assert not widget.is_minimized
        if widget.can_zoom:
            widget.zoom()
            assert Widget.is_zoomed()
            assert Widget.get_zoomed_name() in widget.name
            Widget.close_zoom()
            assert not Widget.is_zoomed()
        widget.footer
        widget.content
示例#16
0
def test_widgets_operation(request):
    sel.force_navigate("dashboard")
    request.addfinalizer(lambda: Widget.close_zoom())
    for widget in Widget.all():
        widget.minimize()
        assert widget.is_minimized
        widget.restore()
        assert not widget.is_minimized
        if widget.can_zoom:
            widget.zoom()
            assert Widget.is_zoomed()
            assert widget.name == Widget.get_zoomed_name()
            Widget.close_zoom()
            assert not Widget.is_zoomed()
        widget.footer
        widget.content
def test_widgets_reorder(widgets, soft_assert):
    """In this test we try to reorder first two widgets in the first column of a
       default dashboard.

       Prerequisities:
        * A list of widgets on the default dashboard

       Steps:
        * Go to the Dashboard
        * Reorder first two widgets in the first column using drag&drop
        * Assert that the widgets order is changed
    """
    first_widget = widgets.all_widgets[0]
    second_widget = widgets.all_widgets[1]
    old_widgets_ids_list = widgets.all_widgets_ids
    first_widget.drag_and_drop(second_widget)
    new_widgets_ids_list = [widget._div_id for widget in Widget.all()]
    (old_widgets_ids_list[0], old_widgets_ids_list[1]) = old_widgets_ids_list[1], old_widgets_ids_list[0]
    soft_assert(old_widgets_ids_list == new_widgets_ids_list, "Drag and drop failed.")
示例#18
0
def test_verify_rss_links(widgets_generated):
    """This test verifies that RSS links on dashboard are working.

    Prerequisities:
        * Generated widgets, at least one RSS.

    Steps:
        * Loop through all RSS widgets
        * Loop through all the links in a widget
        * Try making a request on the provided URLs, should make sense
    """
    pytest.sel.force_navigate("dashboard")
    for widget in Widget.by_type("rss_widget"):
        for desc, date, url in widget.content.data:
            assert url is not None, "Widget {}, line {} - no URL!".format(
                repr(widget.name), repr(desc))
            req = requests.get(url, verify=False)
            assert 200 <= req.status_code < 400, "The url {} seems malformed".format(
                repr(url))
示例#19
0
def test_drag_and_drop_widget_to_the_bottom_of_another_column(widgets, soft_assert):
    """In this test we try to drag and drop a left upper widget to
       the bottom of the middle column.

       Prerequisities:
        * A list of widgets on the default dashboard

       Steps:
        * Go to the Dashboard
        * Drag a left upper widget and drop it under the bottom widget of the near column
        * Assert that the widgets order is changed
    """
    first_widget = widgets.all_widgets[0]
    second_widget = widgets.all_widgets[1]
    old_widgets_ids_list = widgets.all_widgets_ids
    first_widget.drag_and_drop(second_widget)
    new_widgets_ids_list = [widget._div_id for widget in Widget.all()]
    soft_assert(old_widgets_ids_list.index(first_widget._div_id) ==
                new_widgets_ids_list.index(second_widget._div_id), "Drag and drop failed.")
示例#20
0
def test_widgets_reorder(widgets, soft_assert):
    """In this test we try to reorder first two widgets in the first column of a
       default dashboard.

       Prerequisities:
        * A list of widgets on the default dashboard

       Steps:
        * Go to the Dashboard
        * Reorder first two widgets in the first column using drag&drop
        * Assert that the widgets order is changed
    """
    first_widget = widgets.all_widgets[0]
    second_widget = widgets.all_widgets[1]
    old_widgets_ids_list = widgets.all_widgets_ids
    first_widget.drag_and_drop(second_widget)
    new_widgets_ids_list = [widget._div_id for widget in Widget.all()]
    (old_widgets_ids_list[0], old_widgets_ids_list[1]
     ) = old_widgets_ids_list[1], old_widgets_ids_list[0]
    soft_assert(old_widgets_ids_list == new_widgets_ids_list,
                "Drag and drop failed.")
示例#21
0
def test_drag_and_drop_widget_to_the_bottom_of_another_column(
        widgets, soft_assert):
    """In this test we try to drag and drop a left upper widget to
       the bottom of the middle column.

       Prerequisities:
        * A list of widgets on the default dashboard

       Steps:
        * Go to the Dashboard
        * Drag a left upper widget and drop it under the bottom widget of the near column
        * Assert that the widgets order is changed
    """
    first_widget = widgets.all_widgets[0]
    second_widget = widgets.all_widgets[1]
    old_widgets_ids_list = widgets.all_widgets_ids
    first_widget.drag_and_drop(second_widget)
    new_widgets_ids_list = [widget._div_id for widget in Widget.all()]
    soft_assert(
        old_widgets_ids_list.index(
            first_widget._div_id) == new_widgets_ids_list.index(
                second_widget._div_id), "Drag and drop failed.")
示例#22
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!")
示例#23
0
def widgets():
    all_widgets = Widget.all()
    Widgets = namedtuple('Widgets', ('all_widgets', 'all_widgets_ids'))
    yield Widgets(all_widgets=all_widgets,
                  all_widgets_ids=[widget._div_id for widget in all_widgets])
    DefaultDashboard.reset_widgets()
def widgets():
    all_widgets = Widget.all()
    Widgets = namedtuple("Widgets", ("all_widgets", "all_widgets_ids"))
    yield Widgets(all_widgets=all_widgets, all_widgets_ids=[widget._div_id for widget in all_widgets])
    DefaultDashboard.reset_widgets()