diff --git a/backoffice/.envs/local/.django b/backoffice/.envs/local/.django index d83d108e..a0fd784e 100644 --- a/backoffice/.envs/local/.django +++ b/backoffice/.envs/local/.django @@ -23,5 +23,4 @@ OPENSEARCH_INDEX_PREFIX=backoffice-backend-local AIRFLOW_BASE_URL=http://airflow-webserver:8080 AIRFLOW_TOKEN=YWlyZmxvdzphaXJmbG93 - SERVICENOW_URL=https://cerntraining.service-now.com diff --git a/backoffice/backoffice/workflows/api/serializers.py b/backoffice/backoffice/workflows/api/serializers.py index 2abb7231..8452342d 100644 --- a/backoffice/backoffice/workflows/api/serializers.py +++ b/backoffice/backoffice/workflows/api/serializers.py @@ -10,12 +10,13 @@ class WorkflowTicketSerializer(serializers.ModelSerializer): + ticket_url = serializers.SerializerMethodField() + class Meta: model = WorkflowTicket fields = "__all__" def get_ticket_url(self, obj): - # Assuming you have a method or a property to generate the URL for a ticket. return ( f"{environ.get('SERVICENOW_URL')}" f"/nav_to.do?uri=/u_request_fulfillment.do?sys_id={obj.ticket_id}" diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index 0c8737dd..a2f84308 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -14,7 +14,10 @@ from rest_framework.test import APIClient from backoffice.workflows import airflow_utils -from backoffice.workflows.api.serializers import WorkflowTicketSerializer +from backoffice.workflows.api.serializers import ( + WorkflowSerializer, + WorkflowTicketSerializer, +) from backoffice.workflows.constants import WORKFLOW_DAGS, StatusChoices, WorkflowType from backoffice.workflows.models import WorkflowTicket @@ -75,6 +78,9 @@ def test_list_anonymous(self): self.assertEqual(response.status_code, 403) + def test_tickets(self): + assert "tickets" in WorkflowSerializer(self.workflow).data + class TestWorkflowSearchViewSet(BaseTransactionTestCase): endpoint = "/api/workflows/search/" @@ -219,6 +225,9 @@ def test_get_ticket_happy_flow(self): assert response.status_code == 200 assert response.data == WorkflowTicketSerializer(self.workflow_ticket).data + def test_ticket_url(self): + assert "ticket_url" in WorkflowTicketSerializer(self.workflow_ticket).data + def test_create_missing_params(self): self.api_client.force_authenticate(user=self.curator) response = self.api_client.post(