From 6659fa1c289033c52750e7eb6fdc1887f31a1a1e Mon Sep 17 00:00:00 2001 From: Katie Worton Date: Fri, 10 Nov 2023 18:21:29 +0000 Subject: [PATCH] commands/submit.py,core/models.py: Print TestRun ID on submit 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 --- squad_client/commands/submit.py | 4 +++- squad_client/core/models.py | 2 +- tests/test_shortcuts.py | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/squad_client/commands/submit.py b/squad_client/commands/submit.py index a8fc241..c782e12 100644 --- a/squad_client/commands/submit.py +++ b/squad_client/commands/submit.py @@ -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, @@ -174,4 +174,6 @@ def run(self, args): attachments=args.attachments, ) + logger.info(f"TESTRUN_ID {testrun_id}") + return True diff --git a/squad_client/core/models.py b/squad_client/core/models.py index fb831c2..b002336 100644 --- a/squad_client/core/models.py +++ b/squad_client/core/models.py @@ -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): diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py index 12dd7ec..944caf3 100644 --- a/tests/test_shortcuts.py +++ b/tests/test_shortcuts.py @@ -67,7 +67,7 @@ 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", @@ -75,7 +75,6 @@ def test_malformed_data(self): 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