示例#1
0
def test_create_graph(config):
    grapher = LookMlGrapher(config)
    grapher.node_map['model_a'] = NodeType.MODEL
    grapher.node_map['explore_a'] = NodeType.EXPLORE
    grapher.node_map['view_a'] = NodeType.VIEW
    grapher.models_to_explores.append(('model_a', 'explore_a'))
    grapher.explores_to_views.append(('explore_a', 'view_a'))
    g = grapher.create_graph()
    assert isinstance(g, nx.DiGraph)
    assert len(g) == 3
示例#2
0
    def run(
        lkml_paths: list[str],
        output: str = "lookml_diagram.png",
        title: str = "Hello, World!",
        **kwargs,
    ):
        # create the LookML grapher
        grapher = LookMlGrapher(config="None")

        # parse LookML and extract graph info from the input files
        grapher.extract_graph_info(lkml_paths)

        # create nx DiGraph object
        g = grapher.create_graph()

        return grapher, g
示例#3
0
def test_plot_graph(config):
    img_file = config['output']
    if os.path.exists(config['output']):
        os.remove(img_file)

    grapher = LookMlGrapher(config)
    grapher.node_map['model_a'] = NodeType.MODEL
    grapher.node_map['explore_a'] = NodeType.EXPLORE
    grapher.node_map['view_a'] = NodeType.VIEW
    grapher.node_map['orphan'] = NodeType.VIEW
    grapher.models_to_explores.append(('model_a', 'explore_a'))
    grapher.explores_to_views.append(('explore_a', 'view_a'))
    grapher.tag_orphans()
    g = grapher.create_graph()

    grapher.plot_graph(g, img_file, "some title")

    assert os.path.exists(img_file)

    if os.path.exists(config['output']):
        os.remove(img_file)
示例#4
0
def test_plot_graph(config):
    img_file = config["output"]
    if os.path.exists(config["output"]):
        os.remove(img_file)

    grapher = LookMlGrapher(config)
    grapher.node_map["model_a"] = NodeType.MODEL
    grapher.node_map["explore_a"] = NodeType.EXPLORE
    grapher.node_map["view_a"] = NodeType.VIEW
    grapher.node_map["orphan"] = NodeType.VIEW
    grapher.models_to_explores.append(("model_a", "explore_a"))
    grapher.explores_to_views.append(("explore_a", "view_a"))
    grapher.tag_orphans()
    g = grapher.create_graph()

    grapher.plot_graph(g, img_file, "some title")

    assert os.path.exists(img_file)

    if os.path.exists(config["output"]):
        os.remove(img_file)