diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index e69c2f3a..3f770cc5 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -136,11 +136,12 @@ def create(self, request): WORKFLOW_DAGS[workflow.workflow_type].initialize, workflow.id, ) - return airflow_utils.trigger_airflow_dag( + airflow_utils.trigger_airflow_dag( WORKFLOW_DAGS[workflow.workflow_type].initialize, str(workflow.id), workflow.data, ) + return Response(serializer.data, status=status.HTTP_201_CREATED) @extend_schema( summary="Partially Updates Author", @@ -183,9 +184,14 @@ def resolve(self, request, pk=None): ) utils.add_decision(pk, request.user, serializer.validated_data["value"]) - return airflow_utils.trigger_airflow_dag( + airflow_utils.trigger_airflow_dag( ResolutionDags[serializer.validated_data["value"]].label, pk, extra_data ) + workflow_serializer = self.serializer_class( + get_object_or_404(Workflow, pk=pk) + ) + + return Response(workflow_serializer.data) @extend_schema( summary="Restart an Author Workflow", diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index 23e19705..8dc2252f 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -215,6 +215,8 @@ def test_patch_admin(self): "test": "test", }, ) + self.assertEqual(response.json()["id"], str(self.workflow.id)) + self.assertIn("decisions", response.json()) def test_patch_anonymous(self): self.api_client.force_authenticate(user=self.user) @@ -360,7 +362,8 @@ def test_create_author(self): url = reverse("api:workflows-authors-list") response = self.api_client.post(url, format="json", data=data) - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, 201) + self.assertEqual(response.json(), data) @pytest.mark.vcr() def test_accept_author(self): @@ -378,7 +381,8 @@ def test_accept_author(self): self.assertEqual( Decision.objects.filter(workflow=self.workflow.id)[0].action, action ) - + self.assertEqual(response.json()["id"], str(self.workflow.id)) + self.assertIn("decisions", response.json()) airflow_utils.delete_workflow_dag( WORKFLOW_DAGS[WorkflowType.AUTHOR_CREATE].approve, self.workflow.id ) @@ -399,6 +403,8 @@ def test_reject_author(self): self.assertEqual( Decision.objects.filter(workflow=self.workflow.id)[0].action, action ) + self.assertEqual(response.json()["id"], str(self.workflow.id)) + self.assertIn("decisions", response.json()) airflow_utils.delete_workflow_dag( WORKFLOW_DAGS[WorkflowType.AUTHOR_CREATE].reject, self.workflow.id