Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
commands/submit.py,core/models.py: Print TestRun ID on submit
Browse files Browse the repository at this point in the history
Add a print of the TestRun ID of the submitted TestRun, to make it
is possible to find the TestRun ID to fetch pushed attachments.

Signed-off-by: Katie Worton <[email protected]>
  • Loading branch information
katieworton committed Nov 10, 2023
1 parent 732493c commit 6659fa1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion squad_client/commands/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def run(self, args):
logger.error("Incompatible metadata detected")
return False

submit_results(
ok, testrun_id = submit_results(
group_project_slug="%s/%s" % (args.group, args.project),
build_version=args.build,
env_slug=args.environment,
Expand All @@ -174,4 +174,6 @@ def run(self, args):
attachments=args.attachments,
)

logger.info(f"TESTRUN_ID {testrun_id}")

return True
2 changes: 1 addition & 1 deletion squad_client/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def submit(self, group=None, project=None, build=None, environment=None,
status_code = response.status_code
if status_code not in [200, 201, 500]:
logger.error('Failed to submit results: %s' % response.text)
return response.ok
return response.ok, response.text

def submitjob(self, group=None, project=None, build=None, environment=None,
backend=None, definition=None):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ def test_malformed_data(self):
metrics = {"metrica": 42}

with self.assertLogs(logger='squad_client.core.models', level=logging.ERROR) as cm:
success = submit_results(
success, testrun_id = submit_results(
group_project_slug="my_group/my_project",
build_version="my_build",
env_slug="my_env",
tests=tests,
metrics=metrics,
metadata=metadata,
)

self.assertIn(
'ERROR:squad_client.core.models:Failed to submit results: There is already a test run with job_id 12345',
cm.output
Expand Down

0 comments on commit 6659fa1

Please sign in to comment.