def test_flow_view_from_flow_id_where_clause(monkeypatch): post = MagicMock(return_value={"data": {"flow": [FLOW_DATA_1]}}) monkeypatch.setattr("prefect.client.client.Client.post", post) FlowView.from_flow_id(flow_id="id-1") assert ('flow(where: { id: { _eq: "id-1" } })' in post.call_args[1]["params"]["query"])
def test_flow_view_from_returns_instance(patch_post, from_method): patch_post({"data": {"flow": [FLOW_DATA_1]}}) if from_method == "flow_id": flow = FlowView.from_flow_id("id-1") elif from_method == "flow_data": # Note the post patch will not be used since there is no query here flow = FlowView._from_flow_data(FLOW_DATA_1) assert flow.flow_id == "id-1" assert flow.serialized_flow == FLOW_DATA_1["serialized_flow"] assert flow.flow == Flow("flow-1") assert flow.name == "name-1" assert flow.settings == {"key-1": "value-1"} assert flow.flow_group_labels == ["label-1"] assert isinstance(flow.run_config, UniversalRun) assert flow.run_config.env == {"ENV-1": "VAL-1"} assert flow.archived is False assert flow.project_name == "project-1" assert flow.core_version == "0.0.0" assert isinstance(flow.storage, Local) assert flow.storage.stored_as_script is True assert flow.storage.path == "fake-path-1.py"