Skip to content

Commit

Permalink
Fix the FlowsClient.get_run() include_flow_description parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Jul 6, 2023
1 parent 5ebcce9 commit 75389cc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixed
~~~~~

- Adjust the ``FlowsClient.get_run()`` ``include_flow_description`` parameter
so it is sent as a lowercase string (``true`` or ``false``). (:pr:`NUMBER`)
11 changes: 9 additions & 2 deletions src/globus_sdk/_testing/data/flows/get_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,21 @@
method="GET",
path=f"/runs/{RUN_ID}",
json=RUN,
match=[query_param_matcher(params={"include_flow_description": False})],
match=[query_param_matcher(params={})],
),
RegisteredResponse(
service="flows",
method="GET",
path=f"/runs/{RUN_ID}",
json=RUN,
match=[query_param_matcher(params={"include_flow_description": "false"})],
),
RegisteredResponse(
service="flows",
method="GET",
path=f"/runs/{RUN_ID}",
json=RUN_WITH_FLOW_DESCRIPTION,
match=[query_param_matcher(params={"include_flow_description": True})],
match=[query_param_matcher(params={"include_flow_description": "true"})],
),
),
)
12 changes: 6 additions & 6 deletions src/globus_sdk/services/flows/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def get_run(
self,
run_id: UUIDLike,
*,
include_flow_description: bool = False,
include_flow_description: bool | None = None,
query_params: dict[str, t.Any] | None = None,
) -> GlobusHTTPResponse:
"""
Expand Down Expand Up @@ -587,14 +587,14 @@ def get_run(
:ref: Flows/paths/~1runs~1{run_id}/get
"""

additional_query_params = query_params or {}
consolidated_query_params = query_params or {}
if include_flow_description is not None:
value = str(include_flow_description).lower() # "true" or "false"
consolidated_query_params["include_flow_description"] = value

return self.get(
f"/runs/{run_id}",
query_params={
"include_flow_description": include_flow_description,
**additional_query_params,
},
query_params=consolidated_query_params,
)

def cancel_run(self, run_id: UUIDLike) -> GlobusHTTPResponse:
Expand Down
32 changes: 20 additions & 12 deletions tests/functional/services/flows/test_get_run.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from globus_sdk._testing import load_response
import pytest

from globus_sdk._testing import get_last_request, load_response

def test_get_run(flows_client):
metadata = load_response(flows_client.get_run).metadata

resp = flows_client.get_run(metadata["run_id"])
assert resp.http_status == 200
assert "flow_description" not in resp


def test_get_run_with_flow_description(flows_client):
@pytest.mark.parametrize("include_flow_description", (None, False, True))
def test_get_run(flows_client, include_flow_description):
metadata = load_response(flows_client.get_run).metadata

resp = flows_client.get_run(metadata["run_id"], include_flow_description=True)
assert resp.http_status == 200
assert "flow_description" in resp
response = flows_client.get_run(
metadata["run_id"],
include_flow_description=include_flow_description,
)
assert response.http_status == 200

request = get_last_request()
if include_flow_description is None:
assert "flow_description" not in response
assert "include_flow_description" not in request.url
elif include_flow_description is False:
assert "flow_description" not in response
assert "include_flow_description=false" in request.url
else: # include_flow_description is True
assert "flow_description" in response
assert "include_flow_description=true" in request.url

0 comments on commit 75389cc

Please sign in to comment.