Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update server-side State.data to accept arbitrary JSON #6896

Merged
merged 9 commits into from
Sep 21, 2022
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
zanieb committed Sep 20, 2022
commit 9d1c90ec79ae07a0ef4eff50ad7d917d8c078948
21 changes: 21 additions & 0 deletions tests/orion/api/test_flow_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,27 @@ async def test_set_flow_run_state_force_skips_orchestration(
assert response2.status_code == status.HTTP_201_CREATED
assert response2.json()["status"] == "ACCEPT"

@pytest.mark.parametrize("data", [1, "test", {"foo": "bar"}])
async def test_set_flow_run_state_accepts_any_jsonable_data(
self, flow_run, client, session, data
):
response = await client.post(
f"/flow_runs/{flow_run.id}/set_state",
json=dict(state=dict(type="COMPLETED", data=data)),
)
assert response.status_code == 201

api_response = OrchestrationResult.parse_obj(response.json())
assert api_response.status == responses.SetStateStatus.ACCEPT

flow_run_id = flow_run.id
session.expire(flow_run)

run = await models.flow_runs.read_flow_run(
session=session, flow_run_id=flow_run_id
)
assert run.state.data == data


class TestFlowRunHistory:
async def test_history_interval_must_be_one_second_or_larger(self, client):
Expand Down