Exemplo n.º 1
0
def test_trigger_node_in_subgraph(tmp_path: Path):
    dr = set_tmp_dir(tmp_path).parent / "graph"
    name = "sub/graph.yml"
    run_cli("create graph", f"{dr}\n")
    path = dr / name
    run_cli(f"create node", f"{path}\n")
    name = (dr / "sub/p.py").as_posix()
    run_cli(f"create node", f"{name}\n")

    with request_mocker() as m:
        m.post(
            API_BASE_URL + Endpoints.DEPLOYMENTS_TRIGGER_NODE,
            json={"uid": "1"},
        )
        m.get(
            API_BASE_URL + Endpoints.graph_by_slug("test-org-uid", "graph"),
            json={"uid": "2"},
        )
        m.get(
            API_BASE_URL + Endpoints.graphs_latest("2"),
            json={"active_graph_version": {
                "uid": "3"
            }},
        )
        result = run_cli(f"trigger {name}")
        assert "Triggered node" in result.output
Exemplo n.º 2
0
def test_list_data(tmp_path: Path):
    dr = set_tmp_dir(tmp_path).parent
    path = dr / "name"
    node = path / "node.py"
    run_cli(f"create graph {path}")
    run_cli(f"create node {node}")

    store_name = "test"

    with request_mocker() as m:
        m.get(
            API_BASE_URL + Endpoints.graph_by_slug("test-org-uid", "name"),
            json={"uid": "1"},
        )
        m.get(
            API_BASE_URL + Endpoints.OUTPUT_DATA,
            json={
                "results": [{
                    "name": "name"
                }],
                "next": None
            },
        )
        result = run_cli(f"list output {store_name} -g {path} --json")
    assert "name" in result.output
Exemplo n.º 3
0
def test_deploy(tmp_path: Path):
    dr = set_tmp_dir(tmp_path).parent
    path = dr / "name"

    with request_mocker() as m:
        for e in [
                Endpoints.graph_version_create("test-org-uid"),
                Endpoints.DEPLOYMENTS_DEPLOY,
        ]:
            m.post(
                API_BASE_URL + e,
                json={
                    "uid": "1",
                    "ui_url": "url.com",
                    "graph": {
                        "name": "g"
                    },
                    "manifest": {}
                },
            )
        for e in [
                Endpoints.graph_by_slug("test-org-uid", "name"),
                Endpoints.graphs_latest("1"),
        ]:
            m.get(
                API_BASE_URL + e,
                json={
                    "uid": "1",
                    "active_graph_version": {
                        "uid": "1"
                    }
                },
            )

        run_cli(f"create graph {path}")

        result = run_cli(f"upload --no-deploy {path}")
        assert "Uploaded new graph" in result.output
        assert "Graph deployed" not in result.output

        result = run_cli(f"deploy --graph={path}")
        assert "deployed" in result.output
Exemplo n.º 4
0
def test_list_webhooks(tmp_path: Path):
    dr = set_tmp_dir(tmp_path).parent
    path = dr / "name"
    name = "deployed_webhook"
    run_cli(f"create graph {path}")
    run_cli(f"create webhook --graph='{path}' undeployed_webhook")
    with request_mocker() as m:
        m.get(
            API_BASE_URL + Endpoints.graph_by_slug("test-org-uid", "name"),
            json={"uid": "1"},
        )
        m.get(
            API_BASE_URL + Endpoints.WEBHOOKS,
            json={
                "results": [{
                    "name": name
                }],
                "next": None
            },
        )
        result = run_cli(f"list webhooks --json {path}")
    assert name in result.output
Exemplo n.º 5
0
def test_list_logs(tmp_path: Path):
    dr = set_tmp_dir(tmp_path).parent
    path = dr / "name"
    node = path / "node.py"
    run_cli(f"create graph {path}")
    run_cli(f"create node {node}")
    with request_mocker() as m:
        m.get(
            API_BASE_URL + Endpoints.graph_by_slug("test-org-uid", "name"),
            json={"uid": "1"},
        )
        m.get(
            API_BASE_URL + Endpoints.EXECUTION_EVENTS,
            json={
                "results": [{
                    "name": "name"
                }],
                "next": None
            },
        )
        result = run_cli(f"list logs {node} --json")
    assert "name" in result.output
Exemplo n.º 6
0
def get_graph_by_slug(organization_uid: str, slug: str) -> dict:
    return get_json(Endpoints.graph_by_slug(organization_uid, slug))