Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
basic tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Aug 16, 2024
1 parent 109a795 commit 8cb8a98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion backoffice/.envs/local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion backoffice/backoffice/workflows/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
11 changes: 10 additions & 1 deletion backoffice/backoffice/workflows/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/"
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8cb8a98

Please sign in to comment.