Ejemplo n.º 1
0
def test_flow_view_query_for_flow_uses_where_in_query(monkeypatch):
    post = MagicMock(return_value={"data": {"flow": [FLOW_DATA_1]}})
    monkeypatch.setattr("prefect.client.client.Client.post", post)

    FlowView._query_for_flow(where={"foo": {"_eq": "bar"}})

    assert ('flow(where: { foo: { _eq: "bar" } })'
            in post.call_args[1]["params"]["query"])
Ejemplo n.º 2
0
def test_flow_view_query_for_flow_includes_all_required_data(monkeypatch):
    graphql = MagicMock(return_value={"data": {"flow": [FLOW_DATA_1]}})
    monkeypatch.setattr("prefect.client.client.Client.graphql", graphql)

    FlowView._query_for_flow(where={})

    query_dict = graphql.call_args[0][0]
    selection_set = query_dict["query"]["flow(where: {})"]
    assert selection_set == {
        "id": True,
        "settings": True,
        "run_config": True,
        "serialized_flow": True,
        "flow_group": {"labels"},
        "name": True,
        "archived": True,
        "project": {"name"},
        "core_version": True,
        "storage": True,
    }
Ejemplo n.º 3
0
def test_flow_view_query_for_flow_unpacks_result_singleton(patch_post):
    patch_post({"data": {"flow": [1]}})

    assert FlowView._query_for_flow(where={}) == 1
Ejemplo n.º 4
0
def test_flow_view_query_for_flow_errors_on_multiple_flows(patch_post):
    patch_post({"data": {"flow": [1, 2]}})

    with pytest.raises(ValueError, match=r"multiple \(2\) flows"):
        FlowView._query_for_flow(where={})
Ejemplo n.º 5
0
def test_flow_view_query_for_flow_raises_when_not_found(patch_post):
    patch_post({"data": {"flow": []}})

    with pytest.raises(ValueError,
                       match="No results found while querying for flows"):
        FlowView._query_for_flow(where={})
Ejemplo n.º 6
0
def test_flow_view_query_for_flow_raises_bad_responses(patch_post):
    patch_post({})

    with pytest.raises(ValueError,
                       match="bad result while querying for flows"):
        FlowView._query_for_flow(where={})