Example #1
0
def _render_graph_title_elements(graph_artwork, graph_render_options):
    if not graph_render_options["show_title"]:
        return []

    # Hard override of the graph title. This is e.g. needed for the graph previews
    if "title" in graph_render_options:
        return [(graph_render_options["title"], None)]

    title_elements: List[Tuple[str, Optional[str]]] = []

    title_format = transform_graph_render_options_title_format(graph_render_options["title_format"])

    if "plain" in title_format:
        title_elements.append((graph_artwork["title"], None))

    # Only add host/service information for template based graphs
    ident_type, spec_info = graph_artwork["definition"]["specification"]
    if ident_type != "template":
        return title_elements

    title_elements.extend(title_info_elements(spec_info, title_format))

    return title_elements
def test_transform_graph_render_options_title_format(entry, result):
    assert valuespecs.transform_graph_render_options_title_format(
        entry) == result