Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix 400 Bad Request: Cannot update runtime status of entry from waiti…
Browse files Browse the repository at this point in the history
…ng to running
Yifan Zhang authored and Yifan Zhang committed Aug 30, 2023
1 parent 68ed7d1 commit 6fb3ac0
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 12 additions & 3 deletions testplan/runnable/interactive/http.py
Original file line number Diff line number Diff line change
@@ -827,14 +827,23 @@ def _should_run(uid, curr_status, new_status):
"""
if new_status == curr_status:
return False

# test entry already triggered
elif (
new_status == RuntimeStatus.RUNNING
and curr_status == RuntimeStatus.WAITING
):
return False

elif new_status == RuntimeStatus.RUNNING:
if curr_status not in (RuntimeStatus.RESETTING, RuntimeStatus.WAITING):
return True
else:

if curr_status == RuntimeStatus.RESETTING:
raise werkzeug.exceptions.BadRequest(
"Cannot update runtime status of entry"
f' "{uid}" from "{curr_status}" to "{new_status}"'
)
return True

return False


4 changes: 3 additions & 1 deletion tests/unit/testplan/runnable/interactive/test_api.py
Original file line number Diff line number Diff line change
@@ -368,7 +368,9 @@ def test_put_validation(self, api_env):
rsp = client.put(api_url, json=json_test)
assert rsp.status_code == 200
rsp = client.put(api_url, json=json_test)
assert rsp.status_code == 400
assert rsp.status_code == 200
json_rsp = rsp.get_json()
assert json_rsp["runtime_status"] == report.RuntimeStatus.WAITING


class TestAllSuites:

0 comments on commit 6fb3ac0

Please sign in to comment.