From 515df4afe7303237d32037ab1ab3cbf96e784b99 Mon Sep 17 00:00:00 2001 From: Charles Oliveira Date: Fri, 10 Nov 2023 10:11:50 -0300 Subject: [PATCH] api/views.py: return recently created testrun after api/submit call This will assist further usage of whatever has been created within the testrun. Signed-off-by: Charles Oliveira --- doc/intro.rst | 3 +++ squad/api/views.py | 2 +- test/api/tests.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/intro.rst b/doc/intro.rst index 10f86a084..154db7708 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -133,6 +133,9 @@ should be automated with a driver program that asks for user input, and them at the end prepares all the data in a consistent way, and submits it to dashboard. +If input data is valid and nothing goes wrong with the request, SQUAD +will return 201 as status code and the test run id in the response body. + Input file formats ------------------ diff --git a/squad/api/views.py b/squad/api/views.py index 0ccceaa05..b89d2df21 100644 --- a/squad/api/views.py +++ b/squad/api/views.py @@ -119,7 +119,7 @@ def add_test_run(request, group_slug, project_slug, version, environment_slug): logger.warning(request.get_full_path() + ": " + str(e)) return HttpResponse(str(e), status=400) - return HttpResponse('', status=201) + return HttpResponse(str(testrun.id), status=201) @csrf_exempt diff --git a/test/api/tests.py b/test/api/tests.py index d026e496f..731048465 100644 --- a/test/api/tests.py +++ b/test/api/tests.py @@ -63,6 +63,7 @@ def test_create_object_hierarchy(self): object_id=testrun.pk, object_repr=force_text(testrun), ) + self.assertEqual(str(response.content.decode()), str(testrun.id)) self.assertEqual( 1, logentry_queryset.count()