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

fix minor issues of interactive mode #988

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion testplan/common/entity/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,9 @@ def run(self):
break_join=lambda: self.aborted is True,
)
if self._runnable.interactive is not None:
return self._runnable.interactive
# for testing purpose
if self.cfg.interactive_block is False:
return self._runnable.interactive
if isinstance(self._runnable.result, Exception):
raise self._runnable.result
return self._runnable.result
Expand Down
15 changes: 12 additions & 3 deletions testplan/runnable/interactive/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 4 additions & 3 deletions testplan/runnable/interactive/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ def _build_dep_graph(self, main_module_file, reload_dirs):
try:
with io.open(main_module_file, "r") as fp:
text = fp.read()
except OSError:
except OSError as exc:
raise RuntimeError(
"Could not run main module {} as a script.".format(
main_module_file
"Could not run main module {} as a script: {}.".format(
main_module_file,
exc,
)
)
else:
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/testplan/runnable/interactive/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down